numbers_and_words 0.11.0 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/lib/numbers_and_words/core_ext/array.rb +2 -2
  3. data/lib/numbers_and_words/core_ext/float.rb +1 -1
  4. data/lib/numbers_and_words/core_ext/integer.rb +1 -1
  5. data/lib/numbers_and_words/helper_classes.rb +1 -1
  6. data/lib/numbers_and_words/helper_classes/array_extensions/helpers.rb +11 -12
  7. data/lib/numbers_and_words/helper_classes/figures_array.rb +1 -4
  8. data/lib/numbers_and_words/helper_classes/words_array.rb +2 -4
  9. data/lib/numbers_and_words/i18n.rb +4 -4
  10. data/lib/numbers_and_words/i18n/initialization.rb +2 -2
  11. data/lib/numbers_and_words/i18n/locales/numbers.en.yml +3 -3
  12. data/lib/numbers_and_words/i18n/locales/numbers.es.yml +86 -25
  13. data/lib/numbers_and_words/i18n/locales/numbers.fr.yml +54 -1
  14. data/lib/numbers_and_words/i18n/locales/numbers.pt-BR.yml +4 -4
  15. data/lib/numbers_and_words/i18n/locales/numbers.pt.yml +0 -1
  16. data/lib/numbers_and_words/i18n/pluralization.rb +2 -3
  17. data/lib/numbers_and_words/i18n/plurals/fr.rb +3 -3
  18. data/lib/numbers_and_words/i18n/plurals/lt.rb +11 -8
  19. data/lib/numbers_and_words/i18n/plurals/lv.rb +3 -3
  20. data/lib/numbers_and_words/i18n/plurals/ru.rb +15 -10
  21. data/lib/numbers_and_words/strategies.rb +1 -1
  22. data/lib/numbers_and_words/strategies/array_joiner.rb +1 -2
  23. data/lib/numbers_and_words/strategies/array_joiner/languages.rb +3 -1
  24. data/lib/numbers_and_words/strategies/array_joiner/languages/base.rb +1 -1
  25. data/lib/numbers_and_words/strategies/array_joiner/languages/es.rb +10 -0
  26. data/lib/numbers_and_words/strategies/array_joiner/languages/families/base.rb +0 -1
  27. data/lib/numbers_and_words/strategies/array_joiner/languages/fr.rb +10 -0
  28. data/lib/numbers_and_words/strategies/figures_converter.rb +1 -2
  29. data/lib/numbers_and_words/strategies/figures_converter/decorators.rb +8 -6
  30. data/lib/numbers_and_words/strategies/figures_converter/decorators/base.rb +2 -2
  31. data/lib/numbers_and_words/strategies/figures_converter/decorators/en/base.rb +1 -1
  32. data/lib/numbers_and_words/strategies/figures_converter/decorators/en/fractional.rb +2 -3
  33. data/lib/numbers_and_words/strategies/figures_converter/decorators/en/integral.rb +1 -1
  34. data/lib/numbers_and_words/strategies/figures_converter/decorators/es.rb +3 -0
  35. data/lib/numbers_and_words/strategies/figures_converter/decorators/es/base.rb +12 -0
  36. data/lib/numbers_and_words/strategies/figures_converter/decorators/es/fractional.rb +38 -0
  37. data/lib/numbers_and_words/strategies/figures_converter/decorators/es/integral.rb +12 -0
  38. data/lib/numbers_and_words/strategies/figures_converter/decorators/fr.rb +3 -0
  39. data/lib/numbers_and_words/strategies/figures_converter/decorators/fr/base.rb +12 -0
  40. data/lib/numbers_and_words/strategies/figures_converter/decorators/fr/fractional.rb +37 -0
  41. data/lib/numbers_and_words/strategies/figures_converter/decorators/fr/integral.rb +12 -0
  42. data/lib/numbers_and_words/strategies/figures_converter/decorators/hu.rb +1 -1
  43. data/lib/numbers_and_words/strategies/figures_converter/decorators/hu/base.rb +1 -1
  44. data/lib/numbers_and_words/strategies/figures_converter/decorators/hu/fractional.rb +2 -3
  45. data/lib/numbers_and_words/strategies/figures_converter/decorators/hu/integral.rb +1 -1
  46. data/lib/numbers_and_words/strategies/figures_converter/decorators/pt-BR/fractional.rb +1 -2
  47. data/lib/numbers_and_words/strategies/figures_converter/decorators/ru/base.rb +1 -1
  48. data/lib/numbers_and_words/strategies/figures_converter/decorators/ru/fractional.rb +2 -3
  49. data/lib/numbers_and_words/strategies/figures_converter/decorators/ru/integral.rb +1 -2
  50. data/lib/numbers_and_words/strategies/figures_converter/decorators/ua/base.rb +1 -1
  51. data/lib/numbers_and_words/strategies/figures_converter/decorators/ua/fractional.rb +2 -3
  52. data/lib/numbers_and_words/strategies/figures_converter/decorators/ua/integral.rb +1 -2
  53. data/lib/numbers_and_words/strategies/figures_converter/languages.rb +1 -1
  54. data/lib/numbers_and_words/strategies/figures_converter/languages/base.rb +1 -1
  55. data/lib/numbers_and_words/strategies/figures_converter/languages/de.rb +9 -9
  56. data/lib/numbers_and_words/strategies/figures_converter/languages/en-GB.rb +1 -1
  57. data/lib/numbers_and_words/strategies/figures_converter/languages/en.rb +17 -19
  58. data/lib/numbers_and_words/strategies/figures_converter/languages/es.rb +50 -25
  59. data/lib/numbers_and_words/strategies/figures_converter/languages/et.rb +1 -2
  60. data/lib/numbers_and_words/strategies/figures_converter/languages/families/base.rb +5 -5
  61. data/lib/numbers_and_words/strategies/figures_converter/languages/families/cyrillic.rb +5 -5
  62. data/lib/numbers_and_words/strategies/figures_converter/languages/families/helpers.rb +10 -14
  63. data/lib/numbers_and_words/strategies/figures_converter/languages/fr.rb +7 -7
  64. data/lib/numbers_and_words/strategies/figures_converter/languages/hu.rb +8 -8
  65. data/lib/numbers_and_words/strategies/figures_converter/languages/ka.rb +8 -10
  66. data/lib/numbers_and_words/strategies/figures_converter/languages/lt.rb +6 -6
  67. data/lib/numbers_and_words/strategies/figures_converter/languages/lv.rb +2 -2
  68. data/lib/numbers_and_words/strategies/figures_converter/languages/pt-BR.rb +24 -26
  69. data/lib/numbers_and_words/strategies/figures_converter/languages/pt.rb +6 -7
  70. data/lib/numbers_and_words/strategies/figures_converter/languages/tr.rb +4 -4
  71. data/lib/numbers_and_words/strategies/figures_converter/options.rb +6 -5
  72. data/lib/numbers_and_words/strategies/figures_converter/options/en-GB/hundreds_with_union.rb +1 -1
  73. data/lib/numbers_and_words/strategies/figures_converter/options/en-GB/ordinal.rb +1 -1
  74. data/lib/numbers_and_words/strategies/figures_converter/options/en-GB/remove_hyphen.rb +1 -1
  75. data/lib/numbers_and_words/strategies/figures_converter/options/en-GB/remove_zero.rb +1 -1
  76. data/lib/numbers_and_words/strategies/figures_converter/options/en/hundreds_with_union.rb +3 -3
  77. data/lib/numbers_and_words/strategies/figures_converter/options/en/ordinal.rb +3 -3
  78. data/lib/numbers_and_words/strategies/figures_converter/options/en/pronounced.rb +14 -23
  79. data/lib/numbers_and_words/strategies/figures_converter/options/en/remove_hyphen.rb +2 -3
  80. data/lib/numbers_and_words/strategies/figures_converter/options/en/remove_zero.rb +2 -2
  81. data/lib/numbers_and_words/strategies/figures_converter/options/es.rb +3 -0
  82. data/lib/numbers_and_words/strategies/figures_converter/options/es/apocopated.rb +28 -0
  83. data/lib/numbers_and_words/strategies/figures_converter/options/es/gender.rb +28 -0
  84. data/lib/numbers_and_words/strategies/figures_converter/options/es/remove_zero.rb +28 -0
  85. data/lib/numbers_and_words/strategies/figures_converter/options/hu/ordinal.rb +3 -3
  86. data/lib/numbers_and_words/strategies/figures_converter/options/pt-BR/gender.rb +2 -2
  87. data/lib/numbers_and_words/strategies/figures_converter/options/pt-BR/ordinal.rb +1 -1
  88. data/lib/numbers_and_words/strategies/figures_converter/options/pt-BR/remove_zero.rb +1 -1
  89. data/lib/numbers_and_words/strategies/figures_converter/options/ru/gender.rb +2 -2
  90. data/lib/numbers_and_words/strategies/figures_converter/options/ua/gender.rb +2 -2
  91. data/lib/numbers_and_words/translations/base.rb +2 -2
  92. data/lib/numbers_and_words/translations/de.rb +5 -5
  93. data/lib/numbers_and_words/translations/es.rb +29 -24
  94. data/lib/numbers_and_words/translations/et.rb +3 -3
  95. data/lib/numbers_and_words/translations/extensions/fraction_significance.rb +4 -5
  96. data/lib/numbers_and_words/translations/families/base.rb +8 -8
  97. data/lib/numbers_and_words/translations/families/cyrillic.rb +6 -6
  98. data/lib/numbers_and_words/translations/families/latin.rb +6 -6
  99. data/lib/numbers_and_words/translations/fr.rb +16 -8
  100. data/lib/numbers_and_words/translations/hu.rb +3 -3
  101. data/lib/numbers_and_words/translations/it.rb +3 -3
  102. data/lib/numbers_and_words/translations/ka.rb +13 -13
  103. data/lib/numbers_and_words/translations/lt.rb +4 -5
  104. data/lib/numbers_and_words/translations/lv.rb +4 -5
  105. data/lib/numbers_and_words/translations/nl.rb +3 -3
  106. data/lib/numbers_and_words/translations/pt-BR.rb +18 -18
  107. data/lib/numbers_and_words/translations/pt.rb +4 -5
  108. data/lib/numbers_and_words/translations/ru.rb +5 -5
  109. data/lib/numbers_and_words/translations/se.rb +2 -2
  110. data/lib/numbers_and_words/translations/tr.rb +3 -4
  111. data/lib/numbers_and_words/translations/ua.rb +3 -3
  112. data/lib/numbers_and_words/version.rb +1 -1
  113. data/lib/numbers_and_words/wrappers.rb +1 -1
  114. data/lib/numbers_and_words/wrappers/float.rb +9 -9
  115. data/lib/numbers_and_words/wrappers/integer.rb +3 -3
  116. metadata +16 -4
  117. data/lib/numbers_and_words/helper_classes/array_extensions/validations.rb +0 -19
  118. data/lib/numbers_and_words/i18n/plurals/pt-BR.rb +0 -15
@@ -4,13 +4,13 @@ module NumbersAndWords
4
4
  include NumbersAndWords::Translations::Families::Cyrillic
5
5
  include NumbersAndWords::Translations::Extensions::FractionSignificance
6
6
 
7
- def micros capacity, number = nil, separator = ' '
7
+ def micros(capacity, number = nil, separator = ' ')
8
8
  micro, prefix = capacity
9
- micros = t(:micro, :count => number)[micro]
9
+ micros = t(:micro, count: number)[micro]
10
10
  [micro_prefix(prefix), micros].compact.join separator
11
11
  end
12
12
 
13
- def micro_prefix capacity
13
+ def micro_prefix(capacity)
14
14
  case capacity
15
15
  when 2 then t(:sub_micro)[2]
16
16
  when 1 then t(:sub_micro)[1]
@@ -1,3 +1,3 @@
1
1
  module NumbersAndWords
2
- VERSION = '0.11.0'
2
+ VERSION = '0.11.1'.freeze
3
3
  end
@@ -1,2 +1,2 @@
1
1
  require 'numbers_and_words/wrappers/integer'
2
- require 'numbers_and_words/wrappers/float'
2
+ require 'numbers_and_words/wrappers/float'
@@ -1,15 +1,15 @@
1
1
  module NumbersAndWords
2
2
  module Wrappers
3
3
  class Float
4
- ZERO_SYMBOL = '0'
4
+ ZERO_SYMBOL = '0'.freeze
5
5
 
6
6
  attr_accessor :number
7
7
 
8
- def initialize number
8
+ def initialize(number)
9
9
  @number = number
10
10
  end
11
11
 
12
- def to_words options = {}
12
+ def to_words(options = {})
13
13
  @options = options
14
14
  words = []
15
15
  words << integral_part_with(options)
@@ -31,29 +31,29 @@ module NumbersAndWords
31
31
 
32
32
  def fractional_part
33
33
  part = parts.last
34
- part += ZERO_SYMBOL*(precision - part.length) if precision
34
+ part += ZERO_SYMBOL * (precision - part.length) if precision
35
35
  part
36
36
  end
37
37
 
38
- def integral_part_with options
38
+ def integral_part_with(options)
39
39
  integral_part.to_i.to_words options.merge(integral_options)
40
40
  end
41
41
 
42
- def fractional_part_with options
42
+ def fractional_part_with(options)
43
43
  fractional_part.to_i.to_words options.merge(fractional_options)
44
44
  end
45
45
 
46
46
  def integral_options
47
- {:integral => {}}
47
+ { integral: {} }
48
48
  end
49
49
 
50
50
  def fractional_options
51
51
  length = precision || fractional_part.length
52
- {:fractional => {:length => length}}
52
+ { fractional: { length: length } }
53
53
  end
54
54
 
55
55
  def fractional_part_is_nil?
56
- 0 == fractional_part.to_i
56
+ fractional_part.to_i.zero?
57
57
  end
58
58
 
59
59
  def precision
@@ -3,11 +3,11 @@ module NumbersAndWords
3
3
  class Integer
4
4
  attr_accessor :number
5
5
 
6
- def initialize number
6
+ def initialize(number)
7
7
  @number = number
8
8
  end
9
9
 
10
- def to_words options = {}
10
+ def to_words(options = {})
11
11
  to_figures_array.to_words options
12
12
  end
13
13
 
@@ -18,4 +18,4 @@ module NumbersAndWords
18
18
  end
19
19
  end
20
20
  end
21
- end
21
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: numbers_and_words
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Lazarev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-26 00:00:00.000000000 Z
11
+ date: 2017-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -69,7 +69,6 @@ files:
69
69
  - lib/numbers_and_words/core_ext/integer.rb
70
70
  - lib/numbers_and_words/helper_classes.rb
71
71
  - lib/numbers_and_words/helper_classes/array_extensions/helpers.rb
72
- - lib/numbers_and_words/helper_classes/array_extensions/validations.rb
73
72
  - lib/numbers_and_words/helper_classes/figures_array.rb
74
73
  - lib/numbers_and_words/helper_classes/words_array.rb
75
74
  - lib/numbers_and_words/i18n.rb
@@ -97,7 +96,6 @@ files:
97
96
  - lib/numbers_and_words/i18n/plurals/lt.rb
98
97
  - lib/numbers_and_words/i18n/plurals/lv.rb
99
98
  - lib/numbers_and_words/i18n/plurals/plurals.rb
100
- - lib/numbers_and_words/i18n/plurals/pt-BR.rb
101
99
  - lib/numbers_and_words/i18n/plurals/ru.rb
102
100
  - lib/numbers_and_words/i18n/plurals/ua.rb
103
101
  - lib/numbers_and_words/strategies.rb
@@ -106,7 +104,9 @@ files:
106
104
  - lib/numbers_and_words/strategies/array_joiner/languages/base.rb
107
105
  - lib/numbers_and_words/strategies/array_joiner/languages/en-GB.rb
108
106
  - lib/numbers_and_words/strategies/array_joiner/languages/en.rb
107
+ - lib/numbers_and_words/strategies/array_joiner/languages/es.rb
109
108
  - lib/numbers_and_words/strategies/array_joiner/languages/families/base.rb
109
+ - lib/numbers_and_words/strategies/array_joiner/languages/fr.rb
110
110
  - lib/numbers_and_words/strategies/array_joiner/languages/hu.rb
111
111
  - lib/numbers_and_words/strategies/array_joiner/languages/pt-BR.rb
112
112
  - lib/numbers_and_words/strategies/array_joiner/languages/ru.rb
@@ -122,6 +122,14 @@ files:
122
122
  - lib/numbers_and_words/strategies/figures_converter/decorators/en/base.rb
123
123
  - lib/numbers_and_words/strategies/figures_converter/decorators/en/fractional.rb
124
124
  - lib/numbers_and_words/strategies/figures_converter/decorators/en/integral.rb
125
+ - lib/numbers_and_words/strategies/figures_converter/decorators/es.rb
126
+ - lib/numbers_and_words/strategies/figures_converter/decorators/es/base.rb
127
+ - lib/numbers_and_words/strategies/figures_converter/decorators/es/fractional.rb
128
+ - lib/numbers_and_words/strategies/figures_converter/decorators/es/integral.rb
129
+ - lib/numbers_and_words/strategies/figures_converter/decorators/fr.rb
130
+ - lib/numbers_and_words/strategies/figures_converter/decorators/fr/base.rb
131
+ - lib/numbers_and_words/strategies/figures_converter/decorators/fr/fractional.rb
132
+ - lib/numbers_and_words/strategies/figures_converter/decorators/fr/integral.rb
125
133
  - lib/numbers_and_words/strategies/figures_converter/decorators/hu.rb
126
134
  - lib/numbers_and_words/strategies/figures_converter/decorators/hu/base.rb
127
135
  - lib/numbers_and_words/strategies/figures_converter/decorators/hu/fractional.rb
@@ -175,6 +183,10 @@ files:
175
183
  - lib/numbers_and_words/strategies/figures_converter/options/en/pronounced.rb
176
184
  - lib/numbers_and_words/strategies/figures_converter/options/en/remove_hyphen.rb
177
185
  - lib/numbers_and_words/strategies/figures_converter/options/en/remove_zero.rb
186
+ - lib/numbers_and_words/strategies/figures_converter/options/es.rb
187
+ - lib/numbers_and_words/strategies/figures_converter/options/es/apocopated.rb
188
+ - lib/numbers_and_words/strategies/figures_converter/options/es/gender.rb
189
+ - lib/numbers_and_words/strategies/figures_converter/options/es/remove_zero.rb
178
190
  - lib/numbers_and_words/strategies/figures_converter/options/hu.rb
179
191
  - lib/numbers_and_words/strategies/figures_converter/options/hu/ordinal.rb
180
192
  - lib/numbers_and_words/strategies/figures_converter/options/pt-BR.rb
@@ -1,19 +0,0 @@
1
- module NumbersAndWords
2
- module ArrayExtensions
3
- module Validations
4
- #VALID_CHARACTERS = ("0".."9").to_a.push(".").freeze
5
-
6
- def validate_figure_array!
7
- #if invalid_characters.any?
8
- # invalid = invalid_characters.uniq.join ', '
9
- # raise "Figures may contain only numbers and `.` (invalid characters: #{invalid})."
10
- #end
11
- #raise "Figures may contain only 1 `.` (#{count '.'} found)." if count(".") > 1
12
- end
13
-
14
- #def invalid_characters
15
- # reject { |character| VALID_CHARACTERS.include? character }
16
- #end
17
- end
18
- end
19
- end
@@ -1,15 +0,0 @@
1
- module NumbersAndWords
2
- module I18n
3
- module Plurals
4
- module PtBr
5
- RULE = lambda { |n| one_conditions(n) ? :one : :other }
6
-
7
- extend self
8
-
9
- def one_conditions n
10
- n == 1
11
- end
12
- end
13
- end
14
- end
15
- end