Sha256: b8856d7645a230635b96c501416fb3c65642f57c727b2ac2d19c7be5ffffb6da
Contents?: true
Size: 604 Bytes
Versions: 2
Compression:
Stored size: 604 Bytes
Contents
module ActiveObject::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) { |p, n| p * n } end def of(&block) Array.new(self, &block) end def roman return("") if zero? return("-#{(-self).roman}") if self < 0 ROMAN_VALUES.each { |k, v| return("#{k}#{(self - v).roman}") if v <= self } end def time Time.at(self) end end Integer.send(:include, ActiveObject::Integer) if ActiveObject.configuration.autoload_integer
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_object-3.1.0 | lib/active_object/integer.rb |
active_object-3.0.0 | lib/active_object/integer.rb |