Module: CousinRoman
- Defined in:
- lib/cousin_roman.rb,
lib/cousin_roman/roman.rb,
lib/cousin_roman/arabian.rb,
lib/cousin_roman/version.rb,
lib/cousin_roman/string_extension.rb,
lib/cousin_roman/integer_extension.rb
Defined Under Namespace
Modules: Arabian, IntegerExtension, Roman, StringExtension
Constant Summary collapse
- LITERALS =
[ 'i', 'I', 'v', 'V', 'x', 'X', 'l', 'L', 'c', 'C', 'd', 'D', 'm', 'M' ]
- ONES =
{ 'i' => 1, 'x' => 10, 'c' => 100, 'm' => 1000 }
- FIVES =
{ 'v' => 5, 'l' => 50, 'd' => 500, }
- SUBTRACTIVES =
{ 'iv' => 4, 'ix' => 9, 'xl' => 40, 'xc' => 90, 'cd' => 400, 'cm' => 900, }
- FACTORS =
ONES.merge(FIVES).merge(SUBTRACTIVES)
- VERSION =
"1.0.8"
Class Method Summary collapse
Class Method Details
.literals_for_pow(pow) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/cousin_roman.rb', line 42 def self.literals_for_pow(pow) one, five = ONES.keys[pow], FIVES.keys[pow] subtractives = if pow.between? 0, 2 skeys = SUBTRACTIVES.keys { 4 => skeys[pow*2], 9 => skeys[pow*2 + 1] } else nil end { one: one, five: five, subtractives: subtractives } end |