Class: NumbersAndWords::Strategies::FiguresConverter::Languages::Hu

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

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

#complex_number_to_wordsObject


32
33
34
35
36
37
38
# File 'lib/numbers_and_words/strategies/figures_converter/languages/hu.rb', line 32

def complex_number_to_words
  count = @figures.capacity_count
  (1..count).map do |capacity|
    @current_capacity = capacity
    capacity_iteration.flatten
  end.reject(&:empty?)
end

#greater_than_2000?Boolean

Returns:

  • (Boolean)

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

def greater_than_2000?
  @figures.length > 4 || (@figures.length == 4 && @figures.last >= 2)
end

#inner_reverse_wordsObject


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

def inner_reverse_words
  @strings.collect { |iteration| iteration.reverse.join }
end

#maybe_ordinal(type) ⇒ Object


56
57
58
# File 'lib/numbers_and_words/strategies/figures_converter/languages/hu.rb', line 56

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

8
9
10
# File 'lib/numbers_and_words/strategies/figures_converter/languages/hu.rb', line 8

def print_words
  inner_reverse_words.reverse.join(greater_than_2000? && '-' || '')
end

#simple_number_to_wordsObject


40
41
42
43
44
45
46
47
48
# File 'lib/numbers_and_words/strategies/figures_converter/languages/hu.rb', line 40

def simple_number_to_words
  if @figures.teens || @figures.tens
    [complex_tens]
  elsif @figures.ones
    [ones]
  else
    []
  end
end

#strings_logicObject


20
21
22
23
24
25
26
27
28
29
30
# File 'lib/numbers_and_words/strategies/figures_converter/languages/hu.rb', line 20

def strings_logic
  if @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