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.
9
10
11
12
|
# File 'lib/numbers_and_words/strategies/figures_converter/options/en/pronounced.rb', line 9
def initialize(proxy, *_args)
@strategy = proxy.strategy
@options = proxy.options
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
7
8
9
|
# File 'lib/numbers_and_words/strategies/figures_converter/options/en/pronounced.rb', line 7
def options
@options
end
|
#strategy ⇒ Object
Returns the value of attribute strategy.
7
8
9
|
# File 'lib/numbers_and_words/strategies/figures_converter/options/en/pronounced.rb', line 7
def strategy
@strategy
end
|
Instance Method Details
#active? ⇒ Boolean
14
15
16
|
# File 'lib/numbers_and_words/strategies/figures_converter/options/en/pronounced.rb', line 14
def active?
@options[:pronounced]
end
|
#handle_hundreds(language, figures) ⇒ Object
40
41
42
43
44
|
# File 'lib/numbers_and_words/strategies/figures_converter/options/en/pronounced.rb', line 40
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
30
31
32
33
34
35
36
37
38
|
# File 'lib/numbers_and_words/strategies/figures_converter/options/en/pronounced.rb', line 30
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
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/numbers_and_words/strategies/figures_converter/options/en/pronounced.rb', line 18
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/numbers_and_words/strategies/figures_converter/options/en/pronounced.rb', line 46
def tens_with_oh(language, figures)
units, tens = *figures.to_a.dup
result = []
if tens.zero?
if units.zero?
result.push 'hundred'
else
result.push language.ones
result.push 'oh'
end
elsif figures.teens
result.push language.teens
elsif figures.tens
result.push language.complex_tens
end
end
|