Class: Wintr::ThreeDigitGroup
- Inherits:
-
Object
- Object
- Wintr::ThreeDigitGroup
- Defined in:
- lib/wintr/three_digit_group.rb
Instance Method Summary collapse
-
#initialize(hundreds, tens, units) ⇒ ThreeDigitGroup
constructor
A new instance of ThreeDigitGroup.
- #to_w ⇒ Object
Constructor Details
#initialize(hundreds, tens, units) ⇒ ThreeDigitGroup
Returns a new instance of ThreeDigitGroup.
3 4 5 |
# File 'lib/wintr/three_digit_group.rb', line 3 def initialize(hundreds, tens, units) @hundreds, @tens, @units = hundreds, tens, units end |
Instance Method Details
#to_w ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/wintr/three_digit_group.rb', line 7 def to_w word_array = [] if @hundreds == '0' && @tens == '0' && @units == '0' '' else word_array << OneDigitGroup.new(@hundreds).to_w word_array << 'hundred' if @hundreds != '0' word_array << 'and' unless @tens == '0' && @units == '0' word_array << TwoDigitGroup.new(@tens, @units).to_w WordArray.new(word_array).to_w end end |