0.0
No commit activity in last 3 years
No release in over 3 years
human_numbers defines the method #to_english on the classes Float and Integer, as well as the method #to_french on the Integer class, for converting numbers to natural language strings. By default, a cardinal number will be returned (one, two, three), but supplying an :ordinal argument will cause it to return an ordinal (first, second, third). It works with numbers whose absolute value is less than 10^33. #to_french supports a second argument for specifying the gender of the word, which can be either :masculine or :feminine.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.1.11, ~> 1.1.11
~> 0.12.0
 Project Readme

human_numbers

human_numbers adds the method #to_english to the Float and Integer classes, as well as the method #to_french to the Integer class, for converting numbers to natural language strings. It can convert numbers either to cardinals (one, two, three) or ordinals (first, second, third). It works with numbers whose absolute value is less than 10^33.

Installation

To install from RubyGems:

gem install human_numbers

To install from a copy of this repository:

rake install

Examples

require 'human_numbers'

puts 1.to_english                      # 'one'
puts -1.to_english                     # 'negative one'
puts 1.to_english :ordinal             # 'first'
puts 1.to_english :cardinal            # 'one'
puts 1.21.to_english                   # 'one point twenty-one'
puts 1.21.to_english :ordinal          # 'one point twenty-first'
puts 1.to_french(:ordinal, :masculine) # 'premier'
puts 1.to_french(:ordinal, :feminine)  # 'première'