Class: NumbersAndWords::Strategies::FiguresConverter::Options::En::Pronounced
- Inherits:
-
Object
- Object
- NumbersAndWords::Strategies::FiguresConverter::Options::En::Pronounced
show all
- Defined in:
- lib/numbers_and_words/strategies/figures_converter/options/en/pronounced.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(proxy, *_args) ⇒ Pronounced
Returns a new instance of Pronounced.
11
12
13
14
|
# File 'lib/numbers_and_words/strategies/figures_converter/options/en/pronounced.rb', line 11
def initialize(proxy, *_args)
@strategy = proxy.strategy
@options = proxy.options
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
9
10
11
|
# File 'lib/numbers_and_words/strategies/figures_converter/options/en/pronounced.rb', line 9
def options
@options
end
|
#strategy ⇒ Object
Returns the value of attribute strategy.
9
10
11
|
# File 'lib/numbers_and_words/strategies/figures_converter/options/en/pronounced.rb', line 9
def strategy
@strategy
end
|
Instance Method Details
#active? ⇒ Boolean
16
17
18
|
# File 'lib/numbers_and_words/strategies/figures_converter/options/en/pronounced.rb', line 16
def active?
@options[:pronounced]
end
|
#handle_hundreds(language, figures) ⇒ Object
42
43
44
45
46
|
# File 'lib/numbers_and_words/strategies/figures_converter/options/en/pronounced.rb', line 42
def handle_hundreds(language, figures)
_units, _tens, hundreds = *figures.to_a.dup
result = tens_with_oh language, figures
result.push hundreds.to_words
end
|
#handle_thousands(language, figures) ⇒ Object
32
33
34
35
36
37
38
39
40
|
# File 'lib/numbers_and_words/strategies/figures_converter/options/en/pronounced.rb', line 32
def handle_thousands(language, figures)
_units, _tens, hundreds, thousands = *figures.to_a.dup
if hundreds.zero?
language.number_without_capacity_to_words + language.complex_number_to_words
else
result = tens_with_oh language, figures
result.push "#{thousands}#{hundreds}".to_i.to_words
end
end
|
#process(language, figures) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/numbers_and_words/strategies/figures_converter/options/en/pronounced.rb', line 20
def process(language, figures)
if figures.capacity_count
handle_thousands language, figures
elsif figures.hundreds
handle_hundreds language, figures
elsif figures.tens || figures.ones
language.simple_number_to_words
else
[]
end
end
|
#tens_with_oh(language, figures) ⇒ Object
48
49
50
51
52
53
54
|
# File 'lib/numbers_and_words/strategies/figures_converter/options/en/pronounced.rb', line 48
def tens_with_oh(language, figures)
units, tens = *figures.to_a.dup
return (units.zero? ? ['hundred'] : [language.ones, 'oh']) if tens.zero?
return [language.teens] if figures.teens
[language.complex_tens]
end
|