Class: Wintr::WeightedDigitArray

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

Instance Method Summary collapse

Constructor Details

#initialize(digit_array, power_of_thousand) ⇒ WeightedDigitArray

Returns a new instance of WeightedDigitArray.



5
6
7
# File 'lib/wintr/weighted_digit_array.rb', line 5

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

Instance Method Details

#digit_array_in_wordsObject



13
14
15
# File 'lib/wintr/weighted_digit_array.rb', line 13

def digit_array_in_words
  DigitArray.new(@digit_array).to_s
end

#power_of_thousand_in_wordsObject



17
18
19
# File 'lib/wintr/weighted_digit_array.rb', line 17

def power_of_thousand_in_words
  POWER_OF_THOUSAND[@power_of_thousand] if digit_array_in_words != ''
end

#to_sObject



9
10
11
# File 'lib/wintr/weighted_digit_array.rb', line 9

def to_s
  [digit_array_in_words, power_of_thousand_in_words].join(' ').strip
end