numbers_and_words 0.11.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,28 +4,24 @@ module NumbersAndWords
|
|
4
4
|
module Languages
|
5
5
|
module Families
|
6
6
|
module Helpers
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
translate method_name, options
|
11
|
-
}
|
7
|
+
def zero(*args)
|
8
|
+
options = args.first || {}
|
9
|
+
translate :zero, options
|
12
10
|
end
|
13
11
|
|
14
|
-
[
|
15
|
-
define_method(method_name)
|
12
|
+
%i[ones teens tens tens_with_ones hundreds].each do |method_name|
|
13
|
+
define_method(method_name) do |*args|
|
16
14
|
options = args.first || {}
|
17
15
|
translate method_name, @figures.send(method_name), options
|
18
|
-
|
16
|
+
end
|
19
17
|
end
|
20
18
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
translate method_name, @current_capacity, options
|
25
|
-
}
|
19
|
+
def megs(*args)
|
20
|
+
options = args.first || {}
|
21
|
+
translate :megs, @current_capacity, options
|
26
22
|
end
|
27
23
|
|
28
|
-
def translate
|
24
|
+
def translate(method_name, *args)
|
29
25
|
translations.send method_name, *args
|
30
26
|
end
|
31
27
|
end
|
@@ -11,27 +11,27 @@ module NumbersAndWords
|
|
11
11
|
words = []
|
12
12
|
capacity_words = words_in_capacity(@current_capacity)
|
13
13
|
words.push(megs) unless capacity_words.empty?
|
14
|
-
words += capacity_words unless
|
14
|
+
words += capacity_words unless thousand? && one?
|
15
15
|
words
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
[translations.ones(1)]
|
18
|
+
def one?
|
19
|
+
words_in_capacity(@current_capacity) == [translations.ones(1)]
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
22
|
+
def thousand?
|
23
23
|
FiguresArray::THOUSAND_CAPACITY == @current_capacity
|
24
24
|
end
|
25
25
|
|
26
26
|
def hundreds
|
27
|
-
super({:
|
27
|
+
super({ pluralize: simple_number_to_words.empty? })
|
28
28
|
end
|
29
29
|
|
30
30
|
def megs
|
31
|
-
super({:
|
31
|
+
super({ number: @figures.number_in_capacity(@current_capacity) })
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
37
|
-
end
|
37
|
+
end
|
@@ -22,7 +22,7 @@ module NumbersAndWords
|
|
22
22
|
number_without_capacity_to_words + complex_number_to_words
|
23
23
|
elsif @figures.hundreds
|
24
24
|
[hundreds_number_to_words]
|
25
|
-
elsif @figures.tens
|
25
|
+
elsif @figures.tens || @figures.ones
|
26
26
|
[simple_number_to_words]
|
27
27
|
else
|
28
28
|
[]
|
@@ -31,10 +31,10 @@ module NumbersAndWords
|
|
31
31
|
|
32
32
|
def complex_number_to_words
|
33
33
|
count = @figures.capacity_count
|
34
|
-
(1..count).map
|
34
|
+
(1..count).map do |capacity|
|
35
35
|
@current_capacity = capacity
|
36
36
|
capacity_iteration.flatten
|
37
|
-
|
37
|
+
end.reject(&:empty?)
|
38
38
|
end
|
39
39
|
|
40
40
|
def simple_number_to_words
|
@@ -47,13 +47,13 @@ module NumbersAndWords
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
[
|
51
|
-
define_method(method_name)
|
52
|
-
super({:
|
53
|
-
|
50
|
+
%i[zero ones teens tens tens_with_ones hundreds megs].each do |method_name|
|
51
|
+
define_method(method_name) do
|
52
|
+
super({ prefix: maybe_ordinal(method_name) })
|
53
|
+
end
|
54
54
|
end
|
55
55
|
|
56
|
-
def maybe_ordinal
|
56
|
+
def maybe_ordinal(type)
|
57
57
|
@options.ordinal.result type
|
58
58
|
end
|
59
59
|
end
|
@@ -11,28 +11,26 @@ module NumbersAndWords
|
|
11
11
|
words = []
|
12
12
|
capacity_words = words_in_capacity(@current_capacity)
|
13
13
|
words.push(megs) unless capacity_words.empty?
|
14
|
-
words += capacity_words unless
|
14
|
+
words += capacity_words unless thousand? && one?
|
15
15
|
words
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
[translations.ones(1)]
|
18
|
+
def one?
|
19
|
+
words_in_capacity(@current_capacity) == [translations.ones(1)]
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
22
|
+
def thousand?
|
23
23
|
FiguresArray::THOUSAND_CAPACITY == @current_capacity
|
24
24
|
end
|
25
25
|
|
26
26
|
def hundreds
|
27
|
-
super({only_hundreds: figures[0, 2] == [0, 0]})
|
27
|
+
super({ only_hundreds: figures[0, 2] == [0, 0] })
|
28
28
|
end
|
29
29
|
|
30
30
|
def megs
|
31
|
-
if @figures.hundreds || @figures.tens || @figures.ones
|
32
|
-
|
33
|
-
|
34
|
-
prefix = nil
|
35
|
-
end
|
31
|
+
prefix = if @figures.hundreds || @figures.tens || @figures.ones
|
32
|
+
:partials
|
33
|
+
end
|
36
34
|
|
37
35
|
super(prefix: prefix)
|
38
36
|
end
|
@@ -11,24 +11,24 @@ module NumbersAndWords
|
|
11
11
|
words = []
|
12
12
|
capacity_words = words_in_capacity(@current_capacity)
|
13
13
|
words.push(megs) unless capacity_words.empty?
|
14
|
-
words += capacity_words unless
|
14
|
+
words += capacity_words unless thousand? && one?
|
15
15
|
words
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
[translations.ones(1)]
|
18
|
+
def one?
|
19
|
+
words_in_capacity(@current_capacity) == [translations.ones(1)]
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
22
|
+
def thousand?
|
23
23
|
FiguresArray::THOUSAND_CAPACITY == @current_capacity
|
24
24
|
end
|
25
25
|
|
26
26
|
def hundreds
|
27
|
-
super({:
|
27
|
+
super({ is_hundred: (figures[1, 2] == [0, 1] && simple_number_to_words.empty?) })
|
28
28
|
end
|
29
29
|
|
30
30
|
def megs
|
31
|
-
super({:
|
31
|
+
super({ number: @figures.number_in_capacity(@current_capacity) })
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -16,11 +16,11 @@ module NumbersAndWords
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def hundreds
|
19
|
-
super({:
|
19
|
+
super({ is_hundred: (figures[1, 2] == [0, 1] && simple_number_to_words.empty?) })
|
20
20
|
end
|
21
21
|
|
22
22
|
def megs
|
23
|
-
super({:
|
23
|
+
super({ number: @figures.number_in_capacity(@current_capacity) })
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -5,10 +5,10 @@ module NumbersAndWords
|
|
5
5
|
class PtBr < Base
|
6
6
|
include Families::Latin
|
7
7
|
|
8
|
-
[
|
9
|
-
define_method(method_name)
|
8
|
+
%i[teens tens tens_with_ones].each do |method_name|
|
9
|
+
define_method(method_name) do
|
10
10
|
super(internal_options)
|
11
|
-
|
11
|
+
end
|
12
12
|
end
|
13
13
|
|
14
14
|
def zero
|
@@ -20,7 +20,7 @@ module NumbersAndWords
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def complex_number_to_words
|
23
|
-
super.reject
|
23
|
+
super.reject(&:nil?)
|
24
24
|
end
|
25
25
|
|
26
26
|
def capacity_iteration
|
@@ -31,26 +31,24 @@ module NumbersAndWords
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def ones
|
34
|
-
super internal_options.merge(
|
34
|
+
super internal_options.merge(is_one_thousand: one_thousand?)
|
35
35
|
end
|
36
36
|
|
37
37
|
def hundreds
|
38
|
-
super(internal_options.merge(
|
38
|
+
super(internal_options.merge(is_hundred: hundred?, is_one_hundred: one_hundred?, gender: gender))
|
39
39
|
end
|
40
40
|
|
41
41
|
def megs
|
42
|
-
super(internal_options.merge(
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
:is_with_comma => is_with_comma?
|
47
|
-
}))
|
42
|
+
super(internal_options.merge(is_one: words_in_capacity(current_capacity) == [translations.ones(1, internal_options)],
|
43
|
+
is_opaque: opaque?,
|
44
|
+
is_without_connector: without_connector?,
|
45
|
+
is_with_comma: with_comma?))
|
48
46
|
end
|
49
47
|
|
50
48
|
private
|
51
49
|
|
52
50
|
def internal_options
|
53
|
-
{:
|
51
|
+
{ gender: gender, prefix: maybe_ordinal }
|
54
52
|
end
|
55
53
|
|
56
54
|
def maybe_ordinal
|
@@ -68,34 +66,34 @@ module NumbersAndWords
|
|
68
66
|
end
|
69
67
|
end
|
70
68
|
|
71
|
-
def
|
72
|
-
figures[0]
|
69
|
+
def hundred?
|
70
|
+
figures[0].zero? && figures[1].zero? && simple_number_to_words.empty?
|
73
71
|
end
|
74
72
|
|
75
|
-
def
|
76
|
-
|
73
|
+
def one_hundred?
|
74
|
+
hundred? && figures[2] == 1
|
77
75
|
end
|
78
76
|
|
79
|
-
def
|
80
|
-
figures.
|
77
|
+
def opaque?
|
78
|
+
figures.opaque? current_capacity
|
81
79
|
end
|
82
80
|
|
83
|
-
def
|
81
|
+
def one_thousand?
|
84
82
|
current_capacity == 1 && figures[0] == 1 && figures.hundreds.nil? && figures.tens.nil?
|
85
83
|
end
|
86
84
|
|
87
|
-
def
|
88
|
-
return false if
|
85
|
+
def without_connector?
|
86
|
+
return false if with_comma?
|
89
87
|
# without connector when there is hundreds and tens_with_ones
|
90
|
-
return true if figures.hundreds
|
88
|
+
return true if figures.hundreds && figures.tens_with_ones
|
91
89
|
# without connector when there is hundreds and tens
|
92
|
-
return true if figures.hundreds
|
90
|
+
return true if figures.hundreds && figures.tens
|
93
91
|
# without connector when there is hundreds and ones
|
94
|
-
return true if figures.hundreds
|
92
|
+
return true if figures.hundreds && figures.ones
|
95
93
|
false
|
96
94
|
end
|
97
95
|
|
98
|
-
def
|
96
|
+
def with_comma?
|
99
97
|
return false unless @current_capacity > 1
|
100
98
|
# if any lower capacity is single word, in portuguese only tens are single words
|
101
99
|
number_under_capacity = figures.number_under_capacity(@current_capacity)
|
@@ -6,23 +6,22 @@ module NumbersAndWords
|
|
6
6
|
include Families::Latin
|
7
7
|
|
8
8
|
def hundreds
|
9
|
-
super({
|
9
|
+
super({ is_hundred: hundred?, is_one_hundred: one_hundred? })
|
10
10
|
end
|
11
11
|
|
12
12
|
def megs
|
13
|
-
super({:
|
13
|
+
super({ is_one: words_in_capacity(@current_capacity) == [@translations.ones(1)] })
|
14
14
|
end
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
|
-
def
|
19
|
-
figures[0]
|
18
|
+
def hundred?
|
19
|
+
figures[0].zero? && figures[1].zero? && simple_number_to_words.empty?
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
23
|
-
|
22
|
+
def one_hundred?
|
23
|
+
hundred? && figures[2] == 1
|
24
24
|
end
|
25
|
-
|
26
25
|
end
|
27
26
|
end
|
28
27
|
end
|
@@ -11,15 +11,15 @@ module NumbersAndWords
|
|
11
11
|
words = []
|
12
12
|
capacity_words = words_in_capacity(@current_capacity)
|
13
13
|
words.push(megs) unless capacity_words.empty?
|
14
|
-
words += capacity_words unless
|
14
|
+
words += capacity_words unless thousand? && one?
|
15
15
|
words
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
[translations.ones(1)]
|
18
|
+
def one?
|
19
|
+
words_in_capacity(@current_capacity) == [translations.ones(1)]
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
22
|
+
def thousand?
|
23
23
|
FiguresArray::THOUSAND_CAPACITY == @current_capacity
|
24
24
|
end
|
25
25
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'numbers_and_words/strategies/figures_converter/options/en'
|
2
2
|
require 'numbers_and_words/strategies/figures_converter/options/en-GB'
|
3
|
-
require 'numbers_and_words/strategies/figures_converter/options/
|
3
|
+
require 'numbers_and_words/strategies/figures_converter/options/es'
|
4
|
+
require 'numbers_and_words/strategies/figures_converter/options/hu'
|
4
5
|
require 'numbers_and_words/strategies/figures_converter/options/pt-BR'
|
6
|
+
require 'numbers_and_words/strategies/figures_converter/options/ru'
|
5
7
|
require 'numbers_and_words/strategies/figures_converter/options/ua'
|
6
|
-
require 'numbers_and_words/strategies/figures_converter/options/hu'
|
7
8
|
|
8
9
|
module NumbersAndWords
|
9
10
|
module Strategies
|
@@ -12,12 +13,12 @@ module NumbersAndWords
|
|
12
13
|
class Proxy
|
13
14
|
attr_accessor :strategy, :options
|
14
15
|
|
15
|
-
def initialize
|
16
|
+
def initialize(strategy, options)
|
16
17
|
@strategy = strategy
|
17
18
|
@options = options
|
18
19
|
end
|
19
20
|
|
20
|
-
def method_missing
|
21
|
+
def method_missing(method_name, *args, &block)
|
21
22
|
Object.const_get(proxy_class_name(method_name)).new self, args, block
|
22
23
|
rescue NameError
|
23
24
|
return nil
|
@@ -25,7 +26,7 @@ module NumbersAndWords
|
|
25
26
|
|
26
27
|
private
|
27
28
|
|
28
|
-
def proxy_class_name
|
29
|
+
def proxy_class_name(method_name)
|
29
30
|
"#{module_name}::#{I18n.language_class_name}::#{method_name.to_s.split('_').collect(&:capitalize).join}"
|
30
31
|
end
|
31
32
|
|
@@ -6,12 +6,12 @@ module NumbersAndWords
|
|
6
6
|
class HundredsWithUnion
|
7
7
|
attr_accessor :strategy, :options
|
8
8
|
|
9
|
-
def initialize
|
9
|
+
def initialize(proxy, *_args)
|
10
10
|
@strategy = proxy.strategy
|
11
11
|
@options = proxy.options
|
12
12
|
end
|
13
13
|
|
14
|
-
def modify_or_leave
|
14
|
+
def modify_or_leave(hundreds)
|
15
15
|
hundreds = "#{hundreds} #{translations.union}" if active? && !round_hundred?
|
16
16
|
hundreds
|
17
17
|
end
|
@@ -34,4 +34,4 @@ module NumbersAndWords
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
37
|
-
end
|
37
|
+
end
|
@@ -8,12 +8,12 @@ module NumbersAndWords
|
|
8
8
|
HUNDRED_TYPE = :hundreds
|
9
9
|
MEGS_TYPE = :megs
|
10
10
|
|
11
|
-
def initialize
|
11
|
+
def initialize(proxy, *_args)
|
12
12
|
@strategy = proxy.strategy
|
13
13
|
@options = proxy.options
|
14
14
|
end
|
15
15
|
|
16
|
-
def result
|
16
|
+
def result(type)
|
17
17
|
@type = type
|
18
18
|
MEGS_TYPE != type ? check_simple_numbers : check_megs_numbers
|
19
19
|
end
|
@@ -57,4 +57,4 @@ module NumbersAndWords
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
60
|
-
end
|
60
|
+
end
|