Sha256: bb3df0b45ca91710af7b7d3c58290e73023e540ae5da2696ef1555dc277064af
Contents?: true
Size: 633 Bytes
Versions: 7
Compression:
Stored size: 633 Bytes
Contents
class Integer ROMAN_VALUES = { "M" => 1000, "CM" => 900, "D" => 500, "CD" => 400, "C" => 100, "XC" => 90, "L" => 50, "XL" => 40, "X" => 10, "IX" => 9, "V" => 5, "IV" => 4, "I" => 1 } def factorial return(1) if zero? 2.upto(self).inject(1) { |product, n| product * n } end def of(&block) Array.new(self, &block) end def roman return("") if zero? return("-#{(-self).roman}") if self < 0 ROMAN_VALUES.each do |key, value| return(key + (self - value).roman) if value <= self end end def time Time.at(self) end end
Version data entries
7 entries across 7 versions & 1 rubygems