Sha256: 39d3be5444b60928d603ac402f364c69238e35e516135ccf7f63e514f4e05151
Contents?: true
Size: 777 Bytes
Versions: 1
Compression:
Stored size: 777 Bytes
Contents
# frozen_string_literal: true module ActiveObject module 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 }.freeze def factorial return 1 if zero? 2.upto(self).inject(1) { |acc, elem| acc * elem } end def of(&block) ::Array.new(self, &block) end def roman return '' if zero? return "-#{(-self).roman}" if negative? ROMAN_VALUES.each { |key, val| return("#{key}#{(self - val).roman}") if val <= self } end def time ::Time.at(self) end end end Integer.include(ActiveObject::Integer) if ActiveObject.configuration.autoload_integer
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_object-5.8.0 | lib/active_object/integer.rb |