numbers_and_words 0.11.3 → 0.11.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +5 -5
  2. data/README.rdoc +59 -9
  3. data/lib/numbers_and_words.rb +2 -0
  4. data/lib/numbers_and_words/core_ext.rb +2 -0
  5. data/lib/numbers_and_words/core_ext/array.rb +2 -0
  6. data/lib/numbers_and_words/core_ext/float.rb +2 -0
  7. data/lib/numbers_and_words/core_ext/integer.rb +2 -0
  8. data/lib/numbers_and_words/helper_classes.rb +2 -0
  9. data/lib/numbers_and_words/helper_classes/array_extensions/helpers.rb +6 -4
  10. data/lib/numbers_and_words/helper_classes/figures_array.rb +2 -0
  11. data/lib/numbers_and_words/helper_classes/words_array.rb +2 -0
  12. data/lib/numbers_and_words/i18n.rb +2 -0
  13. data/lib/numbers_and_words/i18n/initialization.rb +2 -0
  14. data/lib/numbers_and_words/i18n/locales/numbers.hy.yml +7 -0
  15. data/lib/numbers_and_words/i18n/locales/numbers.kz.yml +7 -0
  16. data/lib/numbers_and_words/i18n/pluralization.rb +3 -1
  17. data/lib/numbers_and_words/i18n/plurals/cs.rb +15 -10
  18. data/lib/numbers_and_words/i18n/plurals/fr.rb +5 -3
  19. data/lib/numbers_and_words/i18n/plurals/lt.rb +10 -7
  20. data/lib/numbers_and_words/i18n/plurals/lv.rb +5 -3
  21. data/lib/numbers_and_words/i18n/plurals/plurals.rb +2 -0
  22. data/lib/numbers_and_words/i18n/plurals/ru.rb +15 -10
  23. data/lib/numbers_and_words/i18n/plurals/ua.rb +2 -0
  24. data/lib/numbers_and_words/strategies.rb +2 -0
  25. data/lib/numbers_and_words/strategies/array_joiner.rb +2 -0
  26. data/lib/numbers_and_words/strategies/array_joiner/languages.rb +2 -0
  27. data/lib/numbers_and_words/strategies/array_joiner/languages/base.rb +2 -0
  28. data/lib/numbers_and_words/strategies/array_joiner/languages/cs.rb +2 -0
  29. data/lib/numbers_and_words/strategies/array_joiner/languages/en-GB.rb +2 -0
  30. data/lib/numbers_and_words/strategies/array_joiner/languages/en.rb +2 -0
  31. data/lib/numbers_and_words/strategies/array_joiner/languages/es.rb +2 -0
  32. data/lib/numbers_and_words/strategies/array_joiner/languages/families/base.rb +2 -0
  33. data/lib/numbers_and_words/strategies/array_joiner/languages/fr.rb +2 -0
  34. data/lib/numbers_and_words/strategies/array_joiner/languages/hu.rb +2 -0
  35. data/lib/numbers_and_words/strategies/array_joiner/languages/pt-BR.rb +2 -0
  36. data/lib/numbers_and_words/strategies/array_joiner/languages/ru.rb +2 -0
  37. data/lib/numbers_and_words/strategies/array_joiner/languages/ua.rb +2 -0
  38. data/lib/numbers_and_words/strategies/array_joiner/languages/vi.rb +2 -0
  39. data/lib/numbers_and_words/strategies/figures_converter.rb +2 -0
  40. data/lib/numbers_and_words/strategies/figures_converter/decorators.rb +2 -0
  41. data/lib/numbers_and_words/strategies/figures_converter/decorators/base.rb +2 -0
  42. data/lib/numbers_and_words/strategies/figures_converter/decorators/cs.rb +2 -0
  43. data/lib/numbers_and_words/strategies/figures_converter/decorators/cs/base.rb +2 -0
  44. data/lib/numbers_and_words/strategies/figures_converter/decorators/cs/fractional.rb +2 -0
  45. data/lib/numbers_and_words/strategies/figures_converter/decorators/cs/integral.rb +3 -0
  46. data/lib/numbers_and_words/strategies/figures_converter/decorators/en-GB.rb +2 -0
  47. data/lib/numbers_and_words/strategies/figures_converter/decorators/en-GB/base.rb +2 -0
  48. data/lib/numbers_and_words/strategies/figures_converter/decorators/en-GB/fractional.rb +2 -0
  49. data/lib/numbers_and_words/strategies/figures_converter/decorators/en-GB/integral.rb +2 -0
  50. data/lib/numbers_and_words/strategies/figures_converter/decorators/en.rb +2 -0
  51. data/lib/numbers_and_words/strategies/figures_converter/decorators/en/base.rb +2 -0
  52. data/lib/numbers_and_words/strategies/figures_converter/decorators/en/fractional.rb +2 -0
  53. data/lib/numbers_and_words/strategies/figures_converter/decorators/en/integral.rb +2 -0
  54. data/lib/numbers_and_words/strategies/figures_converter/decorators/es.rb +2 -0
  55. data/lib/numbers_and_words/strategies/figures_converter/decorators/es/base.rb +2 -0
  56. data/lib/numbers_and_words/strategies/figures_converter/decorators/es/fractional.rb +3 -1
  57. data/lib/numbers_and_words/strategies/figures_converter/decorators/es/integral.rb +2 -0
  58. data/lib/numbers_and_words/strategies/figures_converter/decorators/fr.rb +2 -0
  59. data/lib/numbers_and_words/strategies/figures_converter/decorators/fr/base.rb +2 -0
  60. data/lib/numbers_and_words/strategies/figures_converter/decorators/fr/fractional.rb +2 -0
  61. data/lib/numbers_and_words/strategies/figures_converter/decorators/fr/integral.rb +2 -0
  62. data/lib/numbers_and_words/strategies/figures_converter/decorators/hu.rb +2 -0
  63. data/lib/numbers_and_words/strategies/figures_converter/decorators/hu/base.rb +2 -0
  64. data/lib/numbers_and_words/strategies/figures_converter/decorators/hu/fractional.rb +2 -0
  65. data/lib/numbers_and_words/strategies/figures_converter/decorators/hu/integral.rb +2 -0
  66. data/lib/numbers_and_words/strategies/figures_converter/decorators/pt-BR.rb +2 -0
  67. data/lib/numbers_and_words/strategies/figures_converter/decorators/pt-BR/base.rb +2 -0
  68. data/lib/numbers_and_words/strategies/figures_converter/decorators/pt-BR/fractional.rb +2 -0
  69. data/lib/numbers_and_words/strategies/figures_converter/decorators/pt-BR/integral.rb +2 -0
  70. data/lib/numbers_and_words/strategies/figures_converter/decorators/ru.rb +2 -0
  71. data/lib/numbers_and_words/strategies/figures_converter/decorators/ru/base.rb +2 -0
  72. data/lib/numbers_and_words/strategies/figures_converter/decorators/ru/fractional.rb +2 -0
  73. data/lib/numbers_and_words/strategies/figures_converter/decorators/ru/integral.rb +2 -0
  74. data/lib/numbers_and_words/strategies/figures_converter/decorators/ua.rb +2 -0
  75. data/lib/numbers_and_words/strategies/figures_converter/decorators/ua/base.rb +2 -0
  76. data/lib/numbers_and_words/strategies/figures_converter/decorators/ua/fractional.rb +2 -0
  77. data/lib/numbers_and_words/strategies/figures_converter/decorators/ua/integral.rb +2 -0
  78. data/lib/numbers_and_words/strategies/figures_converter/decorators/vi.rb +2 -0
  79. data/lib/numbers_and_words/strategies/figures_converter/decorators/vi/base.rb +2 -0
  80. data/lib/numbers_and_words/strategies/figures_converter/decorators/vi/fractional.rb +2 -0
  81. data/lib/numbers_and_words/strategies/figures_converter/decorators/vi/integral.rb +2 -0
  82. data/lib/numbers_and_words/strategies/figures_converter/languages.rb +4 -0
  83. data/lib/numbers_and_words/strategies/figures_converter/languages/base.rb +2 -0
  84. data/lib/numbers_and_words/strategies/figures_converter/languages/cs.rb +2 -0
  85. data/lib/numbers_and_words/strategies/figures_converter/languages/de.rb +2 -0
  86. data/lib/numbers_and_words/strategies/figures_converter/languages/en-GB.rb +2 -0
  87. data/lib/numbers_and_words/strategies/figures_converter/languages/en.rb +3 -7
  88. data/lib/numbers_and_words/strategies/figures_converter/languages/es.rb +11 -11
  89. data/lib/numbers_and_words/strategies/figures_converter/languages/et.rb +2 -0
  90. data/lib/numbers_and_words/strategies/figures_converter/languages/families/base.rb +2 -0
  91. data/lib/numbers_and_words/strategies/figures_converter/languages/families/cyrillic.rb +2 -0
  92. data/lib/numbers_and_words/strategies/figures_converter/languages/families/helpers.rb +2 -0
  93. data/lib/numbers_and_words/strategies/figures_converter/languages/fr.rb +2 -0
  94. data/lib/numbers_and_words/strategies/figures_converter/languages/hu.rb +2 -0
  95. data/lib/numbers_and_words/strategies/figures_converter/languages/hy.rb +12 -0
  96. data/lib/numbers_and_words/strategies/figures_converter/languages/it.rb +2 -0
  97. data/lib/numbers_and_words/strategies/figures_converter/languages/ka.rb +3 -3
  98. data/lib/numbers_and_words/strategies/figures_converter/languages/kz.rb +12 -0
  99. data/lib/numbers_and_words/strategies/figures_converter/languages/lt.rb +2 -0
  100. data/lib/numbers_and_words/strategies/figures_converter/languages/lv.rb +2 -0
  101. data/lib/numbers_and_words/strategies/figures_converter/languages/nl.rb +3 -3
  102. data/lib/numbers_and_words/strategies/figures_converter/languages/pt-BR.rb +13 -9
  103. data/lib/numbers_and_words/strategies/figures_converter/languages/pt.rb +2 -0
  104. data/lib/numbers_and_words/strategies/figures_converter/languages/ru.rb +2 -0
  105. data/lib/numbers_and_words/strategies/figures_converter/languages/se.rb +2 -0
  106. data/lib/numbers_and_words/strategies/figures_converter/languages/tr.rb +2 -0
  107. data/lib/numbers_and_words/strategies/figures_converter/languages/ua.rb +2 -0
  108. data/lib/numbers_and_words/strategies/figures_converter/languages/vi.rb +4 -0
  109. data/lib/numbers_and_words/strategies/figures_converter/options.rb +15 -2
  110. data/lib/numbers_and_words/strategies/figures_converter/options/base.rb +5 -0
  111. data/lib/numbers_and_words/strategies/figures_converter/options/base/gender.rb +30 -0
  112. data/lib/numbers_and_words/strategies/figures_converter/options/base/ordinal.rb +28 -0
  113. data/lib/numbers_and_words/strategies/figures_converter/options/base/remove_zero.rb +30 -0
  114. data/lib/numbers_and_words/strategies/figures_converter/options/cs.rb +2 -0
  115. data/lib/numbers_and_words/strategies/figures_converter/options/cs/gender.rb +3 -14
  116. data/lib/numbers_and_words/strategies/figures_converter/options/cs/ordinal.rb +3 -15
  117. data/lib/numbers_and_words/strategies/figures_converter/options/cs/remove_zero.rb +3 -17
  118. data/lib/numbers_and_words/strategies/figures_converter/options/en-GB.rb +2 -0
  119. data/lib/numbers_and_words/strategies/figures_converter/options/en-GB/hundreds_with_union.rb +2 -0
  120. data/lib/numbers_and_words/strategies/figures_converter/options/en-GB/ordinal.rb +2 -0
  121. data/lib/numbers_and_words/strategies/figures_converter/options/en-GB/pronounced.rb +2 -0
  122. data/lib/numbers_and_words/strategies/figures_converter/options/en-GB/remove_hyphen.rb +2 -0
  123. data/lib/numbers_and_words/strategies/figures_converter/options/en-GB/remove_zero.rb +2 -0
  124. data/lib/numbers_and_words/strategies/figures_converter/options/en.rb +2 -0
  125. data/lib/numbers_and_words/strategies/figures_converter/options/en/hundreds_with_union.rb +2 -0
  126. data/lib/numbers_and_words/strategies/figures_converter/options/en/ordinal.rb +3 -10
  127. data/lib/numbers_and_words/strategies/figures_converter/options/en/pronounced.rb +6 -13
  128. data/lib/numbers_and_words/strategies/figures_converter/options/en/remove_hyphen.rb +2 -0
  129. data/lib/numbers_and_words/strategies/figures_converter/options/en/remove_zero.rb +3 -17
  130. data/lib/numbers_and_words/strategies/figures_converter/options/es.rb +2 -0
  131. data/lib/numbers_and_words/strategies/figures_converter/options/es/apocopated.rb +2 -0
  132. data/lib/numbers_and_words/strategies/figures_converter/options/es/gender.rb +3 -17
  133. data/lib/numbers_and_words/strategies/figures_converter/options/es/remove_zero.rb +3 -17
  134. data/lib/numbers_and_words/strategies/figures_converter/options/hu.rb +2 -0
  135. data/lib/numbers_and_words/strategies/figures_converter/options/hu/ordinal.rb +3 -50
  136. data/lib/numbers_and_words/strategies/figures_converter/options/pt-BR.rb +2 -0
  137. data/lib/numbers_and_words/strategies/figures_converter/options/pt-BR/gender.rb +3 -18
  138. data/lib/numbers_and_words/strategies/figures_converter/options/pt-BR/ordinal.rb +3 -15
  139. data/lib/numbers_and_words/strategies/figures_converter/options/pt-BR/remove_zero.rb +3 -17
  140. data/lib/numbers_and_words/strategies/figures_converter/options/ru.rb +2 -0
  141. data/lib/numbers_and_words/strategies/figures_converter/options/ru/gender.rb +3 -17
  142. data/lib/numbers_and_words/strategies/figures_converter/options/ua.rb +2 -0
  143. data/lib/numbers_and_words/strategies/figures_converter/options/ua/gender.rb +3 -17
  144. data/lib/numbers_and_words/translations.rb +4 -0
  145. data/lib/numbers_and_words/translations/base.rb +3 -1
  146. data/lib/numbers_and_words/translations/cs.rb +2 -0
  147. data/lib/numbers_and_words/translations/de.rb +2 -0
  148. data/lib/numbers_and_words/translations/en-GB.rb +2 -0
  149. data/lib/numbers_and_words/translations/en.rb +2 -0
  150. data/lib/numbers_and_words/translations/es.rb +10 -5
  151. data/lib/numbers_and_words/translations/et.rb +2 -0
  152. data/lib/numbers_and_words/translations/extensions/fraction_significance.rb +2 -0
  153. data/lib/numbers_and_words/translations/families/base.rb +2 -0
  154. data/lib/numbers_and_words/translations/families/cyrillic.rb +2 -0
  155. data/lib/numbers_and_words/translations/families/latin.rb +2 -0
  156. data/lib/numbers_and_words/translations/fr.rb +9 -7
  157. data/lib/numbers_and_words/translations/hu.rb +2 -0
  158. data/lib/numbers_and_words/translations/hy.rb +21 -0
  159. data/lib/numbers_and_words/translations/it.rb +2 -0
  160. data/lib/numbers_and_words/translations/ka.rb +3 -1
  161. data/lib/numbers_and_words/translations/kz.rb +9 -0
  162. data/lib/numbers_and_words/translations/lt.rb +2 -0
  163. data/lib/numbers_and_words/translations/lv.rb +2 -0
  164. data/lib/numbers_and_words/translations/nl.rb +3 -0
  165. data/lib/numbers_and_words/translations/pt-BR.rb +9 -2
  166. data/lib/numbers_and_words/translations/pt.rb +3 -0
  167. data/lib/numbers_and_words/translations/ru.rb +2 -0
  168. data/lib/numbers_and_words/translations/se.rb +2 -0
  169. data/lib/numbers_and_words/translations/tr.rb +2 -0
  170. data/lib/numbers_and_words/translations/ua.rb +2 -0
  171. data/lib/numbers_and_words/translations/vi.rb +5 -2
  172. data/lib/numbers_and_words/version.rb +3 -1
  173. data/lib/numbers_and_words/wrappers.rb +2 -0
  174. data/lib/numbers_and_words/wrappers/float.rb +3 -1
  175. data/lib/numbers_and_words/wrappers/integer.rb +2 -0
  176. metadata +28 -19
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'numbers_and_words/strategies/figures_converter/decorators/vi/base'
2
4
  require 'numbers_and_words/strategies/figures_converter/decorators/vi/fractional'
3
5
  require 'numbers_and_words/strategies/figures_converter/decorators/vi/integral'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Strategies
3
5
  module FiguresConverter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Strategies
3
5
  module FiguresConverter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Strategies
3
5
  module FiguresConverter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'numbers_and_words/strategies/figures_converter/languages/families/helpers'
2
4
  require 'numbers_and_words/strategies/figures_converter/languages/families/base'
3
5
  require 'numbers_and_words/strategies/figures_converter/languages/base'
@@ -19,6 +21,8 @@ require 'numbers_and_words/strategies/figures_converter/languages/pt-BR'
19
21
  require 'numbers_and_words/strategies/figures_converter/languages/pt'
20
22
  require 'numbers_and_words/strategies/figures_converter/languages/se'
21
23
  require 'numbers_and_words/strategies/figures_converter/languages/tr'
24
+ require 'numbers_and_words/strategies/figures_converter/languages/hy'
25
+ require 'numbers_and_words/strategies/figures_converter/languages/kz'
22
26
 
23
27
  require 'numbers_and_words/strategies/figures_converter/languages/families/cyrillic'
24
28
  require 'numbers_and_words/strategies/figures_converter/languages/ru'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Strategies
3
5
  module FiguresConverter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Strategies
3
5
  module FiguresConverter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Strategies
3
5
  module FiguresConverter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Strategies
3
5
  module FiguresConverter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Strategies
3
5
  module FiguresConverter
@@ -27,14 +29,8 @@ module NumbersAndWords
27
29
  def strings_logic
28
30
  if @options.pronounced.active?
29
31
  @options.pronounced.process self, @figures
30
- elsif @figures.capacity_count
31
- number_without_capacity_to_words + complex_number_to_words
32
- elsif @figures.hundreds
33
- hundreds_number_to_words
34
- elsif @figures.tens || @figures.ones
35
- simple_number_to_words
36
32
  else
37
- []
33
+ super
38
34
  end
39
35
  end
40
36
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Strategies
3
5
  module FiguresConverter
@@ -18,14 +20,10 @@ module NumbersAndWords
18
20
  end
19
21
 
20
22
  def tens_with_ones
21
- if @figures.tens == 2
22
- @translations
23
- .twenties_with_ones(@figures, gender: gender,
24
- is_apocopated: one_apocopated?)
25
- else
26
- super({ gender: gender,
27
- is_apocopated: one_apocopated? })
28
- end
23
+ options = { gender: gender, is_apocopated: one_apocopated? }
24
+ return @translations.twenties_with_ones(@figures, options) if @figures.tens == 2
25
+
26
+ super(options)
29
27
  end
30
28
 
31
29
  def hundreds
@@ -35,6 +33,7 @@ module NumbersAndWords
35
33
 
36
34
  def megs
37
35
  return @translations.megs(1, number: 1) if long_scale_thousand?
36
+
38
37
  super({ number: @figures.number_in_capacity(@current_capacity) })
39
38
  end
40
39
 
@@ -49,12 +48,12 @@ module NumbersAndWords
49
48
 
50
49
  def long_scale_thousand?
51
50
  @current_capacity.odd? &&
52
- @figures.number_in_capacity(@current_capacity - 1) != 0
51
+ !@figures.number_in_capacity(@current_capacity - 1).zero?
53
52
  end
54
53
 
55
54
  def one_apocopated?
56
- true if @current_capacity > 0 && @figures.ones == 1 ||
57
- @options.apocopated.result
55
+ @current_capacity.positive? && @figures.ones == 1 ||
56
+ @options.apocopated.result
58
57
  end
59
58
 
60
59
  def hundred_apocopated?
@@ -65,6 +64,7 @@ module NumbersAndWords
65
64
  @current_capacity ||= 0
66
65
 
67
66
  return :male if @current_capacity >= 2
67
+
68
68
  @options.gender.result
69
69
  end
70
70
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Strategies
3
5
  module FiguresConverter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Strategies
3
5
  module FiguresConverter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Strategies
3
5
  module FiguresConverter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Strategies
3
5
  module FiguresConverter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Strategies
3
5
  module FiguresConverter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Strategies
3
5
  module FiguresConverter
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NumbersAndWords
4
+ module Strategies
5
+ module FiguresConverter
6
+ module Languages
7
+ class Hy < Base
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Strategies
3
5
  module FiguresConverter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Strategies
3
5
  module FiguresConverter
@@ -16,9 +18,7 @@ module NumbersAndWords
16
18
  end
17
19
 
18
20
  def megs
19
- prefix = if @figures.hundreds || @figures.tens || @figures.ones
20
- :partials
21
- end
21
+ prefix = (:partials if @figures.hundreds || @figures.tens || @figures.ones)
22
22
 
23
23
  super(prefix: prefix)
24
24
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NumbersAndWords
4
+ module Strategies
5
+ module FiguresConverter
6
+ module Languages
7
+ class Kz < Base
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Strategies
3
5
  module FiguresConverter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Strategies
3
5
  module FiguresConverter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Strategies
3
5
  module FiguresConverter
@@ -9,10 +11,8 @@ module NumbersAndWords
9
11
 
10
12
  def capacity_iteration
11
13
  if FiguresArray::THOUSAND_CAPACITY == @current_capacity
12
- words = []
13
14
  capacity_words = words_in_capacity(@current_capacity)
14
- words.push megs unless capacity_words.empty?
15
- capacity_words.empty? ? [] : [capacity_words, words].join
15
+ capacity_words.empty? ? [] : [capacity_words, megs].join
16
16
  else
17
17
  super
18
18
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Strategies
3
5
  module FiguresConverter
@@ -56,8 +58,7 @@ module NumbersAndWords
56
58
  def gender
57
59
  return (options.gender.result || :male) if maybe_ordinal
58
60
 
59
- @current_capacity ||= 0
60
- if @current_capacity > 0 && figures[0] == 1
61
+ if current_capacity&.positive? && figures[0] == 1
61
62
  :male
62
63
  else
63
64
  options.gender.result
@@ -77,22 +78,25 @@ module NumbersAndWords
77
78
  end
78
79
 
79
80
  def one_thousand?
80
- current_capacity == 1 && figures[0] == 1 && figures.hundreds.nil? && figures.tens.nil?
81
+ current_capacity == 1 &&
82
+ figures.ones == 1 &&
83
+ figures.tens.nil? &&
84
+ figures.hundreds.nil?
81
85
  end
82
86
 
83
87
  def without_connector?
84
88
  return false if with_comma?
85
- # without connector when there is hundreds and tens_with_ones
86
- return true if figures.hundreds && figures.tens_with_ones
87
- # without connector when there is hundreds and tens
88
- return true if figures.hundreds && figures.tens
89
- # without connector when there is hundreds and ones
90
- return true if figures.hundreds && figures.ones
89
+ return true if figures.hundreds &&
90
+ (figures.tens_with_ones ||
91
+ figures.tens ||
92
+ figures.ones)
93
+
91
94
  false
92
95
  end
93
96
 
94
97
  def with_comma?
95
98
  return false unless @current_capacity > 1
99
+
96
100
  # if any lower capacity is single word, in portuguese only tens are single words
97
101
  number_under_capacity = figures.number_under_capacity(@current_capacity)
98
102
  return false if number_under_capacity < 20
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Strategies
3
5
  module FiguresConverter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Strategies
3
5
  module FiguresConverter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Strategies
3
5
  module FiguresConverter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Strategies
3
5
  module FiguresConverter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Strategies
3
5
  module FiguresConverter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module NumbersAndWords
2
4
  module Strategies
3
5
  module FiguresConverter
@@ -69,6 +71,7 @@ module NumbersAndWords
69
71
 
70
72
  def fraction_length
71
73
  return 0 unless @options.options[:fractional]
74
+
72
75
  @options.options[:fractional][:length]
73
76
  end
74
77
 
@@ -82,6 +85,7 @@ module NumbersAndWords
82
85
  parts.insert(-1, billion_unit).join(' ')
83
86
  else
84
87
  return value if parts.size <= 2
88
+
85
89
  parts.insert(-2, billion_unit).join(' ')
86
90
  end
87
91
  end
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'numbers_and_words/strategies/figures_converter/options/base'
1
4
  require 'numbers_and_words/strategies/figures_converter/options/en'
2
5
  require 'numbers_and_words/strategies/figures_converter/options/en-GB'
3
6
  require 'numbers_and_words/strategies/figures_converter/options/es'
@@ -20,9 +23,19 @@ module NumbersAndWords
20
23
  end
21
24
 
22
25
  def method_missing(method_name, *args, &block)
23
- Object.const_get(proxy_class_name(method_name)).new self, args, block
26
+ method = Object.const_get(proxy_class_name(method_name))
27
+
28
+ if method
29
+ method.new(self, args, block)
30
+ else
31
+ super
32
+ end
24
33
  rescue NameError
25
- return nil
34
+ nil
35
+ end
36
+
37
+ def respond_to_missing?(method_name, include_private = false)
38
+ Object.const_get(proxy_class_name(method_name)) || super
26
39
  end
27
40
 
28
41
  private
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'numbers_and_words/strategies/figures_converter/options/base/gender'
4
+ require 'numbers_and_words/strategies/figures_converter/options/base/ordinal'
5
+ require 'numbers_and_words/strategies/figures_converter/options/base/remove_zero'
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NumbersAndWords
4
+ module Strategies
5
+ module FiguresConverter
6
+ module Options
7
+ module Base
8
+ class Gender
9
+ attr_accessor :strategy, :options
10
+
11
+ def initialize(proxy, *_args)
12
+ @strategy = proxy.strategy
13
+ @options = proxy.options
14
+ end
15
+
16
+ def result
17
+ active? ? @options[:gender].to_sym : :male
18
+ end
19
+
20
+ private
21
+
22
+ def active?
23
+ @options[:gender]
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end