Class: NumbersAndWords::Strategies::FiguresConverter::Languages::En

Inherits:
Base
  • Object
show all
Defined in:
lib/numbers_and_words/strategies/figures_converter/languages/en.rb

Direct Known Subclasses

EnGb

Instance Attribute Summary

Attributes inherited from Base

#decorator, #figures, #language, #options, #translations

Instance Method Summary collapse

Methods inherited from Base

#initialize, #run

Constructor Details

This class inherits a constructor from NumbersAndWords::Strategies::FiguresConverter::Base

Instance Method Details

#hundredsObject



12
13
14
# File 'lib/numbers_and_words/strategies/figures_converter/languages/en.rb', line 12

def hundreds
  maybe_union_after_hundreds super({ prefix: maybe_ordinal(:hundreds) })
end

#maybe_hyphen_separatorObject



41
42
43
# File 'lib/numbers_and_words/strategies/figures_converter/languages/en.rb', line 41

def maybe_hyphen_separator
  @options.remove_hyphen.result
end

#maybe_ordinal(type) ⇒ Object



45
46
47
# File 'lib/numbers_and_words/strategies/figures_converter/languages/en.rb', line 45

def maybe_ordinal(type)
  @options.ordinal.result type
end

#maybe_remove_zeroObject



53
54
55
# File 'lib/numbers_and_words/strategies/figures_converter/languages/en.rb', line 53

def maybe_remove_zero
  @options.remove_zero.result
end

#maybe_union_after_hundreds(translations) ⇒ Object



49
50
51
# File 'lib/numbers_and_words/strategies/figures_converter/languages/en.rb', line 49

def maybe_union_after_hundreds(translations)
  @options.hundreds_with_union.modify_or_leave translations
end

#strings_logicObject



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/numbers_and_words/strategies/figures_converter/languages/en.rb', line 27

def strings_logic
  if @options.pronounced.active?
    @options.pronounced.process self, @figures
  elsif @figures.capacity_count
    number_without_capacity_to_words + complex_number_to_words
  elsif @figures.hundreds
    hundreds_number_to_words
  elsif @figures.tens || @figures.ones
    simple_number_to_words
  else
    []
  end
end

#tens_with_onesObject



20
21
22
23
24
25
# File 'lib/numbers_and_words/strategies/figures_converter/languages/en.rb', line 20

def tens_with_ones
  super({
    separator: maybe_hyphen_separator,
    prefix: maybe_ordinal(:tens_with_ones)
  })
end

#zeroObject



16
17
18
# File 'lib/numbers_and_words/strategies/figures_converter/languages/en.rb', line 16

def zero
  super({ prefix: maybe_ordinal(:zero) }) unless maybe_remove_zero
end