Sha256: cb19f40c5e914b01756d6ccff85a48579bf17a0711653f1d1a0d36ccd70e371b
Contents?: true
Size: 711 Bytes
Versions: 20
Compression:
Stored size: 711 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
20 entries across 20 versions & 1 rubygems