Class: HumaneInteger
- Inherits:
-
Integer
- Object
- Integer
- HumaneInteger
- Defined in:
- lib/humane_integer.rb
Constant Summary collapse
- Ones =
%w[ zero one two three four five six seven eight nine ]
- Teen =
%w[ ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen ]
- Tens =
%w[ zero ten twenty thirty forty fifty sixty seventy eighty ninety ]
- Mega =
%w[ none thousand million billion ]
Instance Method Summary collapse
Instance Method Details
#to_english ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/humane_integer.rb', line 14 def to_english places = to_s.split(//).collect {|s| s.to_i}.reverse name = [] ((places.length + 2) / 3).times do |p| strings = self.class.trio(places[p * 3, 3]) name.push(Mega[p]) if strings.length > 0 and p > 0 name += strings end name.push(Ones[0]) unless name.length > 0 name.reverse.join(" ") end |