Method: Wintr::Number#to_w
- Defined in:
- lib/wintr/number.rb
#to_w ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/wintr/number.rb', line 10 def to_w return 'zero' if @number == 0 word_array = [] digit_array = @number.to_s.chars.to_a power_of_thousand = 0 until digit_array == [] do digit_group = digit_array.pop(3) word_array.unshift(WeightedDigitGroup.new(digit_group, power_of_thousand).to_w) power_of_thousand += 1 end WordArray.new(word_array).to_w end |