0.0
No commit activity in last 3 years
No release in over 3 years
roman_monkey is a set of simple tools for formatting the numbers from 1 to 3999 as roman numerals, as well as, converting and validating the roman numerals themselves.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 2.11
 Project Readme

roman_monkey

Summary

simple roman numerals from 1 to 3999

Description

roman_monkey is a set of simple tools for formatting the numbers from 1 to 3999 as roman numerals, as well as, converting and validating the roman numerals themselves.

Usage

Object instance methods

require 'roman_monkey'
# or require 'fast_roman_monkey'
#   for pre calculated roman numerals

:i_to_roman
:roman_to_i
:roman? # is it a roman numeral?, :roman_to_i equivalent

irb prompt> require 'roman_monkey'
 => true
irb prompt> 1999.i_to_roman
 => "MCMXCIX"
irb prompt> '1999 was a good year'.i_to_roman
 => "MCMXCIX"
irb prompt> "MCMXCIX".roman_to_i
 => 1999
irb prompt> :MCMXCIX.roman_to_i
 => 1999
irb prompt> 'LD'.roman?
 => nil 
irb prompt> 'CDL'.roman?
 => 450 
irb prompt> 4000.i_to_roman
 => nil 
irb prompt> 0.i_to_roman
 => nil 

Simplest usage

require 'roman_numeral'
# for :i_to_roman module method

irb prompt> require 'roman_numeral'
 => true
irb prompt> RomanNumeral.i_to_roman 3888
 => "MMMDCCCLXXXVIII"

To add roman numeral validation

require 'slow_roman'
# for :roman_to_i module method
# or require 'fast_roman'
#   for pre calculated roman numerals

irb prompt> require 'slow_roman'
 => true
irb prompt> RomanNumeral.i_to_roman 3888
 => "MMMDCCCLXXXVIII"
irb prompt> RomanNumeral.roman_to_i "MMMDCCCLXXXVIII"
 => 3888

Requirements

Most likely any recent version of 1.9 ruby works.

Test with rspec ~> 2.11, rspec -fd

Try the software in irb:

irb prompt> load 'spec/support/roman_test.rb'

Note, to find the gem installation directory:

irb prompt> require 'roman_monkey'
irb prompt> $".grep(/roman_monkey/)[0]
irb prompt> Object.new.method(:i_to_roman).source_location
irb prompt> exit

License

Copyright (c) 2013 Bardi Einarsson. Released under the MIT License. See the LICENSE file for further details.