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.
- checksums.yaml +4 -4
- data/lib/numbers_and_words/core_ext/array.rb +2 -2
- data/lib/numbers_and_words/core_ext/float.rb +1 -1
- data/lib/numbers_and_words/core_ext/integer.rb +1 -1
- data/lib/numbers_and_words/helper_classes.rb +1 -1
- data/lib/numbers_and_words/helper_classes/array_extensions/helpers.rb +11 -12
- data/lib/numbers_and_words/helper_classes/figures_array.rb +1 -4
- data/lib/numbers_and_words/helper_classes/words_array.rb +2 -4
- data/lib/numbers_and_words/i18n.rb +4 -4
- data/lib/numbers_and_words/i18n/initialization.rb +2 -2
- data/lib/numbers_and_words/i18n/locales/numbers.en.yml +3 -3
- data/lib/numbers_and_words/i18n/locales/numbers.es.yml +86 -25
- data/lib/numbers_and_words/i18n/locales/numbers.fr.yml +54 -1
- data/lib/numbers_and_words/i18n/locales/numbers.pt-BR.yml +4 -4
- data/lib/numbers_and_words/i18n/locales/numbers.pt.yml +0 -1
- data/lib/numbers_and_words/i18n/pluralization.rb +2 -3
- data/lib/numbers_and_words/i18n/plurals/fr.rb +3 -3
- data/lib/numbers_and_words/i18n/plurals/lt.rb +11 -8
- data/lib/numbers_and_words/i18n/plurals/lv.rb +3 -3
- data/lib/numbers_and_words/i18n/plurals/ru.rb +15 -10
- data/lib/numbers_and_words/strategies.rb +1 -1
- data/lib/numbers_and_words/strategies/array_joiner.rb +1 -2
- data/lib/numbers_and_words/strategies/array_joiner/languages.rb +3 -1
- data/lib/numbers_and_words/strategies/array_joiner/languages/base.rb +1 -1
- data/lib/numbers_and_words/strategies/array_joiner/languages/es.rb +10 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/families/base.rb +0 -1
- data/lib/numbers_and_words/strategies/array_joiner/languages/fr.rb +10 -0
- data/lib/numbers_and_words/strategies/figures_converter.rb +1 -2
- data/lib/numbers_and_words/strategies/figures_converter/decorators.rb +8 -6
- data/lib/numbers_and_words/strategies/figures_converter/decorators/base.rb +2 -2
- data/lib/numbers_and_words/strategies/figures_converter/decorators/en/base.rb +1 -1
- data/lib/numbers_and_words/strategies/figures_converter/decorators/en/fractional.rb +2 -3
- data/lib/numbers_and_words/strategies/figures_converter/decorators/en/integral.rb +1 -1
- data/lib/numbers_and_words/strategies/figures_converter/decorators/es.rb +3 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/es/base.rb +12 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/es/fractional.rb +38 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/es/integral.rb +12 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/fr.rb +3 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/fr/base.rb +12 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/fr/fractional.rb +37 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/fr/integral.rb +12 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/hu.rb +1 -1
- data/lib/numbers_and_words/strategies/figures_converter/decorators/hu/base.rb +1 -1
- data/lib/numbers_and_words/strategies/figures_converter/decorators/hu/fractional.rb +2 -3
- data/lib/numbers_and_words/strategies/figures_converter/decorators/hu/integral.rb +1 -1
- data/lib/numbers_and_words/strategies/figures_converter/decorators/pt-BR/fractional.rb +1 -2
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ru/base.rb +1 -1
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ru/fractional.rb +2 -3
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ru/integral.rb +1 -2
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ua/base.rb +1 -1
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ua/fractional.rb +2 -3
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ua/integral.rb +1 -2
- data/lib/numbers_and_words/strategies/figures_converter/languages.rb +1 -1
- data/lib/numbers_and_words/strategies/figures_converter/languages/base.rb +1 -1
- data/lib/numbers_and_words/strategies/figures_converter/languages/de.rb +9 -9
- data/lib/numbers_and_words/strategies/figures_converter/languages/en-GB.rb +1 -1
- data/lib/numbers_and_words/strategies/figures_converter/languages/en.rb +17 -19
- data/lib/numbers_and_words/strategies/figures_converter/languages/es.rb +50 -25
- data/lib/numbers_and_words/strategies/figures_converter/languages/et.rb +1 -2
- data/lib/numbers_and_words/strategies/figures_converter/languages/families/base.rb +5 -5
- data/lib/numbers_and_words/strategies/figures_converter/languages/families/cyrillic.rb +5 -5
- data/lib/numbers_and_words/strategies/figures_converter/languages/families/helpers.rb +10 -14
- data/lib/numbers_and_words/strategies/figures_converter/languages/fr.rb +7 -7
- data/lib/numbers_and_words/strategies/figures_converter/languages/hu.rb +8 -8
- data/lib/numbers_and_words/strategies/figures_converter/languages/ka.rb +8 -10
- data/lib/numbers_and_words/strategies/figures_converter/languages/lt.rb +6 -6
- data/lib/numbers_and_words/strategies/figures_converter/languages/lv.rb +2 -2
- data/lib/numbers_and_words/strategies/figures_converter/languages/pt-BR.rb +24 -26
- data/lib/numbers_and_words/strategies/figures_converter/languages/pt.rb +6 -7
- data/lib/numbers_and_words/strategies/figures_converter/languages/tr.rb +4 -4
- data/lib/numbers_and_words/strategies/figures_converter/options.rb +6 -5
- data/lib/numbers_and_words/strategies/figures_converter/options/en-GB/hundreds_with_union.rb +1 -1
- data/lib/numbers_and_words/strategies/figures_converter/options/en-GB/ordinal.rb +1 -1
- data/lib/numbers_and_words/strategies/figures_converter/options/en-GB/remove_hyphen.rb +1 -1
- data/lib/numbers_and_words/strategies/figures_converter/options/en-GB/remove_zero.rb +1 -1
- data/lib/numbers_and_words/strategies/figures_converter/options/en/hundreds_with_union.rb +3 -3
- data/lib/numbers_and_words/strategies/figures_converter/options/en/ordinal.rb +3 -3
- data/lib/numbers_and_words/strategies/figures_converter/options/en/pronounced.rb +14 -23
- data/lib/numbers_and_words/strategies/figures_converter/options/en/remove_hyphen.rb +2 -3
- data/lib/numbers_and_words/strategies/figures_converter/options/en/remove_zero.rb +2 -2
- data/lib/numbers_and_words/strategies/figures_converter/options/es.rb +3 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/es/apocopated.rb +28 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/es/gender.rb +28 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/es/remove_zero.rb +28 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/hu/ordinal.rb +3 -3
- data/lib/numbers_and_words/strategies/figures_converter/options/pt-BR/gender.rb +2 -2
- data/lib/numbers_and_words/strategies/figures_converter/options/pt-BR/ordinal.rb +1 -1
- data/lib/numbers_and_words/strategies/figures_converter/options/pt-BR/remove_zero.rb +1 -1
- data/lib/numbers_and_words/strategies/figures_converter/options/ru/gender.rb +2 -2
- data/lib/numbers_and_words/strategies/figures_converter/options/ua/gender.rb +2 -2
- data/lib/numbers_and_words/translations/base.rb +2 -2
- data/lib/numbers_and_words/translations/de.rb +5 -5
- data/lib/numbers_and_words/translations/es.rb +29 -24
- data/lib/numbers_and_words/translations/et.rb +3 -3
- data/lib/numbers_and_words/translations/extensions/fraction_significance.rb +4 -5
- data/lib/numbers_and_words/translations/families/base.rb +8 -8
- data/lib/numbers_and_words/translations/families/cyrillic.rb +6 -6
- data/lib/numbers_and_words/translations/families/latin.rb +6 -6
- data/lib/numbers_and_words/translations/fr.rb +16 -8
- data/lib/numbers_and_words/translations/hu.rb +3 -3
- data/lib/numbers_and_words/translations/it.rb +3 -3
- data/lib/numbers_and_words/translations/ka.rb +13 -13
- data/lib/numbers_and_words/translations/lt.rb +4 -5
- data/lib/numbers_and_words/translations/lv.rb +4 -5
- data/lib/numbers_and_words/translations/nl.rb +3 -3
- data/lib/numbers_and_words/translations/pt-BR.rb +18 -18
- data/lib/numbers_and_words/translations/pt.rb +4 -5
- data/lib/numbers_and_words/translations/ru.rb +5 -5
- data/lib/numbers_and_words/translations/se.rb +2 -2
- data/lib/numbers_and_words/translations/tr.rb +3 -4
- data/lib/numbers_and_words/translations/ua.rb +3 -3
- data/lib/numbers_and_words/version.rb +1 -1
- data/lib/numbers_and_words/wrappers.rb +1 -1
- data/lib/numbers_and_words/wrappers/float.rb +9 -9
- data/lib/numbers_and_words/wrappers/integer.rb +3 -3
- metadata +16 -4
- data/lib/numbers_and_words/helper_classes/array_extensions/validations.rb +0 -19
- 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
|
7
|
+
def micros(capacity, number = nil, separator = ' ')
|
8
8
|
micro, prefix = capacity
|
9
|
-
micros = t(: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
|
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,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
|
8
|
+
def initialize(number)
|
9
9
|
@number = number
|
10
10
|
end
|
11
11
|
|
12
|
-
def to_words
|
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
|
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
|
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
|
-
{:
|
47
|
+
{ integral: {} }
|
48
48
|
end
|
49
49
|
|
50
50
|
def fractional_options
|
51
51
|
length = precision || fractional_part.length
|
52
|
-
{:
|
52
|
+
{ fractional: { length: length } }
|
53
53
|
end
|
54
54
|
|
55
55
|
def fractional_part_is_nil?
|
56
|
-
|
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
|
6
|
+
def initialize(number)
|
7
7
|
@number = number
|
8
8
|
end
|
9
9
|
|
10
|
-
def to_words
|
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.
|
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-
|
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
|