0.0
No release in over 3 years
Low commit activity in last 3 years
This gem allows you to convert integers to Roman numerals and vice versa.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

Romanumerals

RSpec codecov

This gem allows you to convert arabic numbers to roman.

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add romanumerals

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install romanumerals

Usage

Usage is very simple:

Convert to roman:

10.to_roman # => "X" 
110.to_roman # => "CX" 
99.to_roman # => "XCIX"
845.to_roman # => "DCCCXLV"
1193.to_roman # => "MCXCIII"
2024.to_roman # => "MMXXIV"

Convert from roman:

'MMXXIV'.to_numeral # => 2024

Other cases:

0.to_roman # => ""
11.9.to_roman # => "XI"

# If a string does not contain roman numerals then the String#to_i will be used 
''.to_numeral # => 0
'0'.to_numeral # => 0
'XIIi'.to_numeral # => 0
'5 contributors'.to_numeral # => 5

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/febonazzic/romanumerals.

License

The gem is available as open source under the terms of the MIT License.