numbers_and_words 0.11.2 → 0.11.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.rdoc +23 -5
- data/lib/numbers_and_words.rb +2 -0
- data/lib/numbers_and_words/core_ext.rb +2 -0
- data/lib/numbers_and_words/core_ext/array.rb +2 -0
- data/lib/numbers_and_words/core_ext/float.rb +2 -0
- data/lib/numbers_and_words/core_ext/integer.rb +2 -0
- data/lib/numbers_and_words/helper_classes.rb +2 -0
- data/lib/numbers_and_words/helper_classes/array_extensions/helpers.rb +6 -4
- data/lib/numbers_and_words/helper_classes/figures_array.rb +2 -0
- data/lib/numbers_and_words/helper_classes/words_array.rb +2 -0
- data/lib/numbers_and_words/i18n.rb +2 -0
- data/lib/numbers_and_words/i18n/initialization.rb +2 -0
- data/lib/numbers_and_words/i18n/locales/numbers.cs.yml +37 -26
- data/lib/numbers_and_words/i18n/locales/numbers.de.yml +5 -4
- data/lib/numbers_and_words/i18n/locales/numbers.en-GB.yml +24 -8
- data/lib/numbers_and_words/i18n/locales/numbers.en.yml +10 -6
- data/lib/numbers_and_words/i18n/locales/numbers.es.yml +6 -5
- data/lib/numbers_and_words/i18n/locales/numbers.et.yml +4 -4
- data/lib/numbers_and_words/i18n/locales/numbers.fr.yml +45 -41
- data/lib/numbers_and_words/i18n/locales/numbers.hu.yml +11 -7
- data/lib/numbers_and_words/i18n/locales/numbers.hy.yml +7 -0
- data/lib/numbers_and_words/i18n/locales/numbers.it.yml +3 -3
- data/lib/numbers_and_words/i18n/locales/numbers.ka.yml +6 -14
- data/lib/numbers_and_words/i18n/locales/numbers.lt.yml +4 -5
- data/lib/numbers_and_words/i18n/locales/numbers.lv.yml +4 -5
- data/lib/numbers_and_words/i18n/locales/numbers.nl.yml +4 -3
- data/lib/numbers_and_words/i18n/locales/numbers.pt-BR.yml +51 -22
- data/lib/numbers_and_words/i18n/locales/numbers.pt.yml +21 -8
- data/lib/numbers_and_words/i18n/locales/numbers.ru.yml +39 -27
- data/lib/numbers_and_words/i18n/locales/numbers.se.yml +3 -3
- data/lib/numbers_and_words/i18n/locales/numbers.tr.yml +3 -3
- data/lib/numbers_and_words/i18n/locales/numbers.ua.yml +39 -15
- data/lib/numbers_and_words/i18n/locales/numbers.vi.yml +13 -0
- data/lib/numbers_and_words/i18n/pluralization.rb +3 -1
- data/lib/numbers_and_words/i18n/plurals/cs.rb +15 -10
- data/lib/numbers_and_words/i18n/plurals/fr.rb +5 -3
- data/lib/numbers_and_words/i18n/plurals/lt.rb +10 -7
- data/lib/numbers_and_words/i18n/plurals/lv.rb +5 -3
- data/lib/numbers_and_words/i18n/plurals/plurals.rb +2 -0
- data/lib/numbers_and_words/i18n/plurals/ru.rb +15 -10
- data/lib/numbers_and_words/i18n/plurals/ua.rb +2 -0
- data/lib/numbers_and_words/strategies.rb +2 -0
- data/lib/numbers_and_words/strategies/array_joiner.rb +2 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages.rb +3 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/base.rb +2 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/cs.rb +2 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/en-GB.rb +3 -1
- data/lib/numbers_and_words/strategies/array_joiner/languages/en.rb +2 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/es.rb +2 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/families/base.rb +5 -3
- data/lib/numbers_and_words/strategies/array_joiner/languages/fr.rb +2 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/hu.rb +2 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/pt-BR.rb +2 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/ru.rb +2 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/ua.rb +2 -0
- data/lib/numbers_and_words/strategies/array_joiner/languages/vi.rb +12 -0
- data/lib/numbers_and_words/strategies/figures_converter.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators.rb +3 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/base.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/cs.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/cs/base.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/cs/fractional.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/cs/integral.rb +3 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/en-GB.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/en-GB/base.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/en-GB/fractional.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/en-GB/integral.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/en.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/en/base.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/en/fractional.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/en/integral.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/es.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/es/base.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/es/fractional.rb +3 -1
- data/lib/numbers_and_words/strategies/figures_converter/decorators/es/integral.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/fr.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/fr/base.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/fr/fractional.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/fr/integral.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/hu.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/hu/base.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/hu/fractional.rb +3 -1
- data/lib/numbers_and_words/strategies/figures_converter/decorators/hu/integral.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/pt-BR.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/pt-BR/base.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/pt-BR/fractional.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/pt-BR/integral.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ru.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ru/base.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ru/fractional.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ru/integral.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ua.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ua/base.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ua/fractional.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ua/integral.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/vi.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/vi/base.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/vi/fractional.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/vi/integral.rb +14 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages.rb +14 -15
- data/lib/numbers_and_words/strategies/figures_converter/languages/base.rb +4 -2
- data/lib/numbers_and_words/strategies/figures_converter/languages/cs.rb +4 -4
- data/lib/numbers_and_words/strategies/figures_converter/languages/de.rb +7 -7
- data/lib/numbers_and_words/strategies/figures_converter/languages/en-GB.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/en.rb +3 -9
- data/lib/numbers_and_words/strategies/figures_converter/languages/es.rb +11 -13
- data/lib/numbers_and_words/strategies/figures_converter/languages/et.rb +2 -2
- data/lib/numbers_and_words/strategies/figures_converter/languages/families/base.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/families/cyrillic.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/families/helpers.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/fr.rb +12 -12
- data/lib/numbers_and_words/strategies/figures_converter/languages/hu.rb +2 -2
- data/lib/numbers_and_words/strategies/figures_converter/languages/{families/latin.rb → hy.rb} +3 -4
- data/lib/numbers_and_words/strategies/figures_converter/languages/it.rb +2 -1
- data/lib/numbers_and_words/strategies/figures_converter/languages/ka.rb +13 -15
- data/lib/numbers_and_words/strategies/figures_converter/languages/lt.rb +8 -12
- data/lib/numbers_and_words/strategies/figures_converter/languages/lv.rb +4 -14
- data/lib/numbers_and_words/strategies/figures_converter/languages/nl.rb +3 -5
- data/lib/numbers_and_words/strategies/figures_converter/languages/pt-BR.rb +14 -12
- data/lib/numbers_and_words/strategies/figures_converter/languages/pt.rb +3 -3
- data/lib/numbers_and_words/strategies/figures_converter/languages/ru.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/se.rb +2 -1
- data/lib/numbers_and_words/strategies/figures_converter/languages/tr.rb +4 -4
- data/lib/numbers_and_words/strategies/figures_converter/languages/ua.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/vi.rb +100 -0
- data/lib/numbers_and_words/strategies/figures_converter/options.rb +15 -2
- data/lib/numbers_and_words/strategies/figures_converter/options/base.rb +5 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/base/gender.rb +30 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/base/ordinal.rb +28 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/base/remove_zero.rb +30 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/cs.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/cs/gender.rb +3 -14
- data/lib/numbers_and_words/strategies/figures_converter/options/cs/ordinal.rb +3 -15
- data/lib/numbers_and_words/strategies/figures_converter/options/cs/remove_zero.rb +3 -17
- data/lib/numbers_and_words/strategies/figures_converter/options/en-GB.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/en-GB/hundreds_with_union.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/en-GB/ordinal.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/en-GB/pronounced.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/en-GB/remove_hyphen.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/en-GB/remove_zero.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/en.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/en/hundreds_with_union.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/en/ordinal.rb +3 -10
- data/lib/numbers_and_words/strategies/figures_converter/options/en/pronounced.rb +6 -13
- data/lib/numbers_and_words/strategies/figures_converter/options/en/remove_hyphen.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/en/remove_zero.rb +3 -17
- data/lib/numbers_and_words/strategies/figures_converter/options/es.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/es/apocopated.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/es/gender.rb +3 -17
- data/lib/numbers_and_words/strategies/figures_converter/options/es/remove_zero.rb +3 -17
- data/lib/numbers_and_words/strategies/figures_converter/options/hu.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/hu/ordinal.rb +3 -50
- data/lib/numbers_and_words/strategies/figures_converter/options/pt-BR.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/pt-BR/gender.rb +3 -18
- data/lib/numbers_and_words/strategies/figures_converter/options/pt-BR/ordinal.rb +3 -15
- data/lib/numbers_and_words/strategies/figures_converter/options/pt-BR/remove_zero.rb +3 -17
- data/lib/numbers_and_words/strategies/figures_converter/options/ru.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ru/gender.rb +3 -17
- data/lib/numbers_and_words/strategies/figures_converter/options/ua.rb +2 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ua/gender.rb +3 -17
- data/lib/numbers_and_words/translations.rb +4 -0
- data/lib/numbers_and_words/translations/base.rb +3 -1
- data/lib/numbers_and_words/translations/cs.rb +6 -31
- data/lib/numbers_and_words/translations/de.rb +5 -3
- data/lib/numbers_and_words/translations/en-GB.rb +5 -1
- data/lib/numbers_and_words/translations/en.rb +2 -0
- data/lib/numbers_and_words/translations/es.rb +15 -25
- data/lib/numbers_and_words/translations/et.rb +4 -7
- data/lib/numbers_and_words/translations/extensions/fraction_significance.rb +6 -4
- data/lib/numbers_and_words/translations/families/base.rb +5 -3
- data/lib/numbers_and_words/translations/families/cyrillic.rb +6 -8
- data/lib/numbers_and_words/translations/families/latin.rb +2 -0
- data/lib/numbers_and_words/translations/fr.rb +15 -18
- data/lib/numbers_and_words/translations/hu.rb +4 -7
- data/lib/numbers_and_words/translations/hy.rb +21 -0
- data/lib/numbers_and_words/translations/it.rb +2 -0
- data/lib/numbers_and_words/translations/ka.rb +6 -14
- data/lib/numbers_and_words/translations/lt.rb +4 -11
- data/lib/numbers_and_words/translations/lv.rb +4 -11
- data/lib/numbers_and_words/translations/nl.rb +6 -2
- data/lib/numbers_and_words/translations/pt-BR.rb +23 -23
- data/lib/numbers_and_words/translations/pt.rb +5 -11
- data/lib/numbers_and_words/translations/ru.rb +2 -17
- data/lib/numbers_and_words/translations/se.rb +2 -0
- data/lib/numbers_and_words/translations/tr.rb +2 -4
- data/lib/numbers_and_words/translations/ua.rb +2 -13
- data/lib/numbers_and_words/translations/vi.rb +24 -0
- data/lib/numbers_and_words/version.rb +3 -1
- data/lib/numbers_and_words/wrappers.rb +2 -0
- data/lib/numbers_and_words/wrappers/float.rb +3 -1
- data/lib/numbers_and_words/wrappers/integer.rb +2 -0
- metadata +33 -20
@@ -1,18 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module NumbersAndWords
|
2
4
|
module Strategies
|
3
5
|
module FiguresConverter
|
4
6
|
module Options
|
5
7
|
module En
|
6
|
-
class Ordinal
|
8
|
+
class Ordinal < Base::Ordinal
|
7
9
|
ZERO_TYPE = :zero
|
8
10
|
HUNDRED_TYPE = :hundreds
|
9
11
|
MEGS_TYPE = :megs
|
10
12
|
|
11
|
-
def initialize(proxy, *_args)
|
12
|
-
@strategy = proxy.strategy
|
13
|
-
@options = proxy.options
|
14
|
-
end
|
15
|
-
|
16
13
|
def result(type)
|
17
14
|
@type = type
|
18
15
|
MEGS_TYPE != type ? check_simple_numbers : check_megs_numbers
|
@@ -20,10 +17,6 @@ module NumbersAndWords
|
|
20
17
|
|
21
18
|
private
|
22
19
|
|
23
|
-
def active?
|
24
|
-
@options[:ordinal]
|
25
|
-
end
|
26
|
-
|
27
20
|
def check_simple_numbers
|
28
21
|
:ordinal if simple_numbers_condition && active?
|
29
22
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module NumbersAndWords
|
2
4
|
module Strategies
|
3
5
|
module FiguresConverter
|
@@ -45,19 +47,10 @@ module NumbersAndWords
|
|
45
47
|
|
46
48
|
def tens_with_oh(language, figures)
|
47
49
|
units, tens = *figures.to_a.dup
|
48
|
-
|
49
|
-
if
|
50
|
-
|
51
|
-
|
52
|
-
else
|
53
|
-
result.push language.ones
|
54
|
-
result.push 'oh'
|
55
|
-
end
|
56
|
-
elsif figures.teens
|
57
|
-
result.push language.teens
|
58
|
-
elsif figures.tens
|
59
|
-
result.push language.complex_tens
|
60
|
-
end
|
50
|
+
return (units.zero? ? ['hundred'] : [language.ones, 'oh']) if tens.zero?
|
51
|
+
return [language.teens] if figures.teens
|
52
|
+
|
53
|
+
[language.complex_tens]
|
61
54
|
end
|
62
55
|
end
|
63
56
|
end
|
@@ -1,25 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module NumbersAndWords
|
2
4
|
module Strategies
|
3
5
|
module FiguresConverter
|
4
6
|
module Options
|
5
7
|
module En
|
6
|
-
class RemoveZero
|
7
|
-
attr_accessor :strategy, :options
|
8
|
-
|
9
|
-
def initialize(proxy, *_args)
|
10
|
-
@strategy = proxy.strategy
|
11
|
-
@options = proxy.options
|
12
|
-
end
|
13
|
-
|
14
|
-
def result
|
15
|
-
active?
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def active?
|
21
|
-
@options[:remove_zero]
|
22
|
-
end
|
8
|
+
class RemoveZero < Base::RemoveZero
|
23
9
|
end
|
24
10
|
end
|
25
11
|
end
|
@@ -1,25 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module NumbersAndWords
|
2
4
|
module Strategies
|
3
5
|
module FiguresConverter
|
4
6
|
module Options
|
5
7
|
module Es
|
6
|
-
class Gender
|
7
|
-
attr_accessor :strategy, :options
|
8
|
-
|
9
|
-
def initialize(proxy, *_args)
|
10
|
-
@strategy = proxy.strategy
|
11
|
-
@options = proxy.options
|
12
|
-
end
|
13
|
-
|
14
|
-
def result
|
15
|
-
active? ? @options[:gender].to_sym : :male
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def active?
|
21
|
-
@options[:gender]
|
22
|
-
end
|
8
|
+
class Gender < Base::Gender
|
23
9
|
end
|
24
10
|
end
|
25
11
|
end
|
@@ -1,25 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module NumbersAndWords
|
2
4
|
module Strategies
|
3
5
|
module FiguresConverter
|
4
6
|
module Options
|
5
7
|
module Es
|
6
|
-
class RemoveZero
|
7
|
-
attr_accessor :strategy, :options
|
8
|
-
|
9
|
-
def initialize(proxy, *_args)
|
10
|
-
@strategy = proxy.strategy
|
11
|
-
@options = proxy.options
|
12
|
-
end
|
13
|
-
|
14
|
-
def result
|
15
|
-
active?
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def active?
|
21
|
-
@options[:remove_zero]
|
22
|
-
end
|
8
|
+
class RemoveZero < Base::RemoveZero
|
23
9
|
end
|
24
10
|
end
|
25
11
|
end
|
@@ -1,58 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module NumbersAndWords
|
2
4
|
module Strategies
|
3
5
|
module FiguresConverter
|
4
6
|
module Options
|
5
7
|
module Hu
|
6
|
-
class Ordinal
|
7
|
-
ZERO_TYPE = :zero
|
8
|
-
HUNDRED_TYPE = :hundreds
|
9
|
-
MEGS_TYPE = :megs
|
10
|
-
|
11
|
-
def initialize(proxy, *_args)
|
12
|
-
@strategy = proxy.strategy
|
13
|
-
@options = proxy.options
|
14
|
-
end
|
15
|
-
|
16
|
-
def result(type)
|
17
|
-
@type = type
|
18
|
-
MEGS_TYPE != type ? check_simple_numbers : check_megs_numbers
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def active?
|
24
|
-
@options[:ordinal]
|
25
|
-
end
|
26
|
-
|
27
|
-
def check_simple_numbers
|
28
|
-
:ordinal if simple_numbers_condition && active?
|
29
|
-
end
|
30
|
-
|
31
|
-
def check_megs_numbers
|
32
|
-
:ordinal if megs_numbers_condition && active?
|
33
|
-
end
|
34
|
-
|
35
|
-
def simple_numbers_condition
|
36
|
-
current_capacity.nil? &&
|
37
|
-
(HUNDRED_TYPE != @type ||
|
38
|
-
HUNDRED_TYPE == @type && simple_number_to_words.empty?)
|
39
|
-
end
|
40
|
-
|
41
|
-
def megs_numbers_condition
|
42
|
-
current_capacity == language_figures.ordinal_capacity
|
43
|
-
end
|
44
|
-
|
45
|
-
def simple_number_to_words
|
46
|
-
@strategy.language.simple_number_to_words
|
47
|
-
end
|
48
|
-
|
49
|
-
def current_capacity
|
50
|
-
@strategy.language.current_capacity
|
51
|
-
end
|
52
|
-
|
53
|
-
def language_figures
|
54
|
-
@strategy.language.parent_figures
|
55
|
-
end
|
8
|
+
class Ordinal < En::Ordinal
|
56
9
|
end
|
57
10
|
end
|
58
11
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'numbers_and_words/strategies/figures_converter/options/pt-BR/gender'
|
2
4
|
require 'numbers_and_words/strategies/figures_converter/options/pt-BR/ordinal'
|
3
5
|
require 'numbers_and_words/strategies/figures_converter/options/pt-BR/remove_zero'
|
@@ -1,26 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module NumbersAndWords
|
2
4
|
module Strategies
|
3
5
|
module FiguresConverter
|
4
6
|
module Options
|
5
7
|
module PtBr
|
6
|
-
class Gender
|
7
|
-
attr_accessor :strategy, :options
|
8
|
-
|
9
|
-
def initialize(proxy, *_args)
|
10
|
-
@strategy = proxy.strategy
|
11
|
-
@options = proxy.options
|
12
|
-
end
|
13
|
-
|
14
|
-
def result
|
15
|
-
gender = active? ? @options[:gender].to_sym : :male
|
16
|
-
%i[male female].include?(gender) ? gender : :male
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def active?
|
22
|
-
@options[:gender]
|
23
|
-
end
|
8
|
+
class Gender < Base::Gender
|
24
9
|
end
|
25
10
|
end
|
26
11
|
end
|
@@ -1,23 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module NumbersAndWords
|
2
4
|
module Strategies
|
3
5
|
module FiguresConverter
|
4
6
|
module Options
|
5
7
|
module PtBr
|
6
|
-
class Ordinal
|
7
|
-
def initialize(proxy, *_args)
|
8
|
-
@strategy = proxy.strategy
|
9
|
-
@options = proxy.options
|
10
|
-
end
|
11
|
-
|
12
|
-
def result
|
13
|
-
return :ordinal if active?
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def active?
|
19
|
-
@options[:ordinal]
|
20
|
-
end
|
8
|
+
class Ordinal < Base::Ordinal
|
21
9
|
end
|
22
10
|
end
|
23
11
|
end
|
@@ -1,25 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module NumbersAndWords
|
2
4
|
module Strategies
|
3
5
|
module FiguresConverter
|
4
6
|
module Options
|
5
7
|
module PtBr
|
6
|
-
class RemoveZero
|
7
|
-
attr_accessor :strategy, :options
|
8
|
-
|
9
|
-
def initialize(proxy, *_args)
|
10
|
-
@strategy = proxy.strategy
|
11
|
-
@options = proxy.options
|
12
|
-
end
|
13
|
-
|
14
|
-
def result
|
15
|
-
active?
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def active?
|
21
|
-
@options[:remove_zero]
|
22
|
-
end
|
8
|
+
class RemoveZero < Base::RemoveZero
|
23
9
|
end
|
24
10
|
end
|
25
11
|
end
|
@@ -1,25 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module NumbersAndWords
|
2
4
|
module Strategies
|
3
5
|
module FiguresConverter
|
4
6
|
module Options
|
5
7
|
module Ru
|
6
|
-
class Gender
|
7
|
-
attr_accessor :strategy, :options
|
8
|
-
|
9
|
-
def initialize(proxy, *_args)
|
10
|
-
@strategy = proxy.strategy
|
11
|
-
@options = proxy.options
|
12
|
-
end
|
13
|
-
|
14
|
-
def result
|
15
|
-
active? ? @options[:gender].to_sym : :male
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def active?
|
21
|
-
@options[:gender]
|
22
|
-
end
|
8
|
+
class Gender < Base::Gender
|
23
9
|
end
|
24
10
|
end
|
25
11
|
end
|
@@ -1,25 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module NumbersAndWords
|
2
4
|
module Strategies
|
3
5
|
module FiguresConverter
|
4
6
|
module Options
|
5
7
|
module Ua
|
6
|
-
class Gender
|
7
|
-
attr_accessor :strategy, :options
|
8
|
-
|
9
|
-
def initialize(proxy, *_args)
|
10
|
-
@strategy = proxy.strategy
|
11
|
-
@options = proxy.options
|
12
|
-
end
|
13
|
-
|
14
|
-
def result
|
15
|
-
active? ? @options[:gender].to_sym : :male
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def active?
|
21
|
-
@options[:gender]
|
22
|
-
end
|
8
|
+
class Gender < Base::Gender
|
23
9
|
end
|
24
10
|
end
|
25
11
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'numbers_and_words/translations/base'
|
2
4
|
require 'numbers_and_words/translations/families/base'
|
3
5
|
require 'numbers_and_words/translations/families/cyrillic'
|
@@ -22,6 +24,8 @@ require 'numbers_and_words/translations/pt'
|
|
22
24
|
require 'numbers_and_words/translations/pt-BR'
|
23
25
|
require 'numbers_and_words/translations/ka'
|
24
26
|
require 'numbers_and_words/translations/cs'
|
27
|
+
require 'numbers_and_words/translations/vi'
|
28
|
+
require 'numbers_and_words/translations/hy'
|
25
29
|
|
26
30
|
module NumbersAndWords
|
27
31
|
module Translations
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module NumbersAndWords
|
2
4
|
module Translations
|
3
5
|
class Base
|
4
6
|
I18N_NAMESPACE = :numbers
|
5
7
|
|
6
8
|
def t(attribute, options = {})
|
7
|
-
::I18n.t attribute, options.merge(scope: I18N_NAMESPACE)
|
9
|
+
::I18n.t attribute, **options.merge(scope: I18N_NAMESPACE)
|
8
10
|
end
|
9
11
|
end
|
10
12
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module NumbersAndWords
|
2
4
|
module Translations
|
3
5
|
class Cs < Base
|
@@ -12,53 +14,26 @@ module NumbersAndWords
|
|
12
14
|
t([options[:prefix], :ones, options[:gender]].join('.'))[number]
|
13
15
|
end
|
14
16
|
|
15
|
-
# for 20, 30, 60
|
16
17
|
def tens(number, options = {})
|
17
18
|
t([options[:prefix], :tens, gender_to_use(options)].join('.'))[number]
|
18
19
|
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
t([options[:prefix], :teens, gender_to_use(options)].join('.'))[number_arr.first]
|
21
|
+
def teens(numbers, options = {})
|
22
|
+
t([options[:prefix], :teens, gender_to_use(options)].join('.'))[numbers[0]]
|
23
23
|
end
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
connector = ' '
|
28
|
-
[tens(numbers_arr[1], options), connector, ones(numbers_arr[0], options)].join
|
25
|
+
def tens_with_ones(numbers, options = {})
|
26
|
+
[tens(numbers[1], options), ones(numbers[0], options)].join(' ')
|
29
27
|
end
|
30
28
|
|
31
29
|
def hundreds(number, options = {})
|
32
30
|
t([options[:prefix], :hundreds, gender_to_use(options)].join('.'))[number]
|
33
31
|
end
|
34
32
|
|
35
|
-
def megs(capacity, options = {})
|
36
|
-
number = options[:number]
|
37
|
-
mega_name = "#{options[:prefix]}.mega"
|
38
|
-
number ? t(mega(capacity), count: number) : t(mega_name)[capacity]
|
39
|
-
end
|
40
|
-
|
41
|
-
def mega(capacity)
|
42
|
-
t(:mega)[capacity]
|
43
|
-
end
|
44
|
-
|
45
33
|
def integral(number, _options = {})
|
46
34
|
t(:integral, count: number)
|
47
35
|
end
|
48
36
|
|
49
|
-
def micros(capacity, number = nil, separator = '')
|
50
|
-
micro, prefix = capacity
|
51
|
-
micros = t(:micro, count: number)[micro]
|
52
|
-
[micro_prefix(prefix), micros].compact.join separator
|
53
|
-
end
|
54
|
-
|
55
|
-
def micro_prefix(capacity)
|
56
|
-
case capacity
|
57
|
-
when 2 then t(:sub_micro)[2]
|
58
|
-
when 1 then t(:sub_micro)[1]
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
37
|
private
|
63
38
|
|
64
39
|
def ordinal?(options)
|