Class: Wintr::WeightedDigitGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/wintr/weighted_digit_group.rb

Instance Method Summary collapse

Constructor Details

#initialize(digit_group, power_of_thousand) ⇒ WeightedDigitGroup

Returns a new instance of WeightedDigitGroup.



7
8
9
# File 'lib/wintr/weighted_digit_group.rb', line 7

def initialize(digit_group, power_of_thousand)
  @digit_group, @power_of_thousand = digit_group, power_of_thousand
end

Instance Method Details

#to_sObject



11
12
13
14
15
# File 'lib/wintr/weighted_digit_group.rb', line 11

def to_s
  base_digit_group_in_words = DigitGroup.new(@digit_group).to_s
  power_of_thousand_in_words = PowerOfThousand.new(@power_of_thousand).to_s if base_digit_group_in_words != ''
  WordArray.new([base_digit_group_in_words, power_of_thousand_in_words]).to_s
end