Sha256: 4132990ea6f6bf4f7993ea23aa0620d510587a6fb5ccba5c7bfa4e676dde7454
Contents?: true
Size: 776 Bytes
Versions: 12
Compression:
Stored size: 776 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
12 entries across 12 versions & 1 rubygems