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,16 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module NumbersAndWords
|
2
4
|
module Strategies
|
3
5
|
module FiguresConverter
|
4
6
|
module Languages
|
5
7
|
class De < Base
|
6
|
-
include Families::Latin
|
7
|
-
|
8
8
|
def print_words
|
9
|
-
complex_part.count > 1 ? print_megs_words : @strings.flatten.reverse.join
|
9
|
+
complex_part.count > 1 ? print_megs_words : @strings.flatten.reverse.join
|
10
10
|
end
|
11
11
|
|
12
12
|
def print_megs_words
|
13
|
-
[print_megs, print_other].reject(&:empty?).join
|
13
|
+
[print_megs, print_other].reject(&:empty?).join(' ')
|
14
14
|
end
|
15
15
|
|
16
16
|
def complex_number_to_words
|
@@ -40,16 +40,16 @@ module NumbersAndWords
|
|
40
40
|
|
41
41
|
def print_megs
|
42
42
|
complex_part[1..-1].map do |el|
|
43
|
-
[el[1..-1].to_a.reverse.join
|
43
|
+
[el[1..-1].to_a.reverse.join, el.first].join(' ')
|
44
44
|
end.reject(&:empty?).reverse.join(' ')
|
45
45
|
end
|
46
46
|
|
47
47
|
def print_other
|
48
|
-
[print_thousands, simple_part.reverse.join
|
48
|
+
[print_thousands, simple_part.reverse.join].join
|
49
49
|
end
|
50
50
|
|
51
51
|
def print_thousands
|
52
|
-
complex_part.first.reverse.join
|
52
|
+
complex_part.first.reverse.join
|
53
53
|
end
|
54
54
|
|
55
55
|
def simple_part
|
@@ -1,10 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module NumbersAndWords
|
2
4
|
module Strategies
|
3
5
|
module FiguresConverter
|
4
6
|
module Languages
|
5
7
|
class En < Base
|
6
|
-
include Families::Latin
|
7
|
-
|
8
8
|
%i[ones teens tens megs].each do |method_name|
|
9
9
|
define_method(method_name) do
|
10
10
|
super({ prefix: maybe_ordinal(method_name) })
|
@@ -29,14 +29,8 @@ module NumbersAndWords
|
|
29
29
|
def strings_logic
|
30
30
|
if @options.pronounced.active?
|
31
31
|
@options.pronounced.process self, @figures
|
32
|
-
elsif @figures.capacity_count
|
33
|
-
number_without_capacity_to_words + complex_number_to_words
|
34
|
-
elsif @figures.hundreds
|
35
|
-
hundreds_number_to_words
|
36
|
-
elsif @figures.tens || @figures.ones
|
37
|
-
simple_number_to_words
|
38
32
|
else
|
39
|
-
|
33
|
+
super
|
40
34
|
end
|
41
35
|
end
|
42
36
|
|
@@ -1,10 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module NumbersAndWords
|
2
4
|
module Strategies
|
3
5
|
module FiguresConverter
|
4
6
|
module Languages
|
5
7
|
class Es < Base
|
6
|
-
include Families::Latin
|
7
|
-
|
8
8
|
def capacity_iteration
|
9
9
|
super.compact
|
10
10
|
end
|
@@ -20,14 +20,10 @@ module NumbersAndWords
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def tens_with_ones
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
else
|
28
|
-
super({ gender: gender,
|
29
|
-
is_apocopated: one_apocopated? })
|
30
|
-
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)
|
31
27
|
end
|
32
28
|
|
33
29
|
def hundreds
|
@@ -37,6 +33,7 @@ module NumbersAndWords
|
|
37
33
|
|
38
34
|
def megs
|
39
35
|
return @translations.megs(1, number: 1) if long_scale_thousand?
|
36
|
+
|
40
37
|
super({ number: @figures.number_in_capacity(@current_capacity) })
|
41
38
|
end
|
42
39
|
|
@@ -51,12 +48,12 @@ module NumbersAndWords
|
|
51
48
|
|
52
49
|
def long_scale_thousand?
|
53
50
|
@current_capacity.odd? &&
|
54
|
-
|
51
|
+
!@figures.number_in_capacity(@current_capacity - 1).zero?
|
55
52
|
end
|
56
53
|
|
57
54
|
def one_apocopated?
|
58
|
-
|
59
|
-
|
55
|
+
@current_capacity.positive? && @figures.ones == 1 ||
|
56
|
+
@options.apocopated.result
|
60
57
|
end
|
61
58
|
|
62
59
|
def hundred_apocopated?
|
@@ -67,6 +64,7 @@ module NumbersAndWords
|
|
67
64
|
@current_capacity ||= 0
|
68
65
|
|
69
66
|
return :male if @current_capacity >= 2
|
67
|
+
|
70
68
|
@options.gender.result
|
71
69
|
end
|
72
70
|
|
@@ -1,12 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module NumbersAndWords
|
2
4
|
module Strategies
|
3
5
|
module FiguresConverter
|
4
6
|
module Languages
|
5
7
|
class Fr < Base
|
6
|
-
include Families::Latin
|
7
|
-
|
8
|
-
private
|
9
|
-
|
10
8
|
def capacity_iteration
|
11
9
|
words = []
|
12
10
|
capacity_words = words_in_capacity(@current_capacity)
|
@@ -15,14 +13,6 @@ module NumbersAndWords
|
|
15
13
|
words
|
16
14
|
end
|
17
15
|
|
18
|
-
def one?
|
19
|
-
words_in_capacity(@current_capacity) == [translations.ones(1)]
|
20
|
-
end
|
21
|
-
|
22
|
-
def thousand?
|
23
|
-
FiguresArray::THOUSAND_CAPACITY == @current_capacity
|
24
|
-
end
|
25
|
-
|
26
16
|
def hundreds
|
27
17
|
super({ pluralize: simple_number_to_words.empty? })
|
28
18
|
end
|
@@ -30,6 +20,16 @@ module NumbersAndWords
|
|
30
20
|
def megs
|
31
21
|
super({ number: @figures.number_in_capacity(@current_capacity) })
|
32
22
|
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def one?
|
27
|
+
words_in_capacity(@current_capacity) == [translations.ones(1)]
|
28
|
+
end
|
29
|
+
|
30
|
+
def thousand?
|
31
|
+
FiguresArray::THOUSAND_CAPACITY == @current_capacity
|
32
|
+
end
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module NumbersAndWords
|
2
4
|
module Strategies
|
3
5
|
module FiguresConverter
|
4
6
|
module Languages
|
5
7
|
class Hu < Base
|
6
|
-
include Families::Latin
|
7
|
-
|
8
8
|
def print_words
|
9
9
|
inner_reverse_words.reverse.join(greater_than_2000? && '-' || '')
|
10
10
|
end
|
@@ -1,12 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module NumbersAndWords
|
2
4
|
module Strategies
|
3
5
|
module FiguresConverter
|
4
6
|
module Languages
|
5
7
|
class Ka < Base
|
6
|
-
include Families::Latin
|
7
|
-
|
8
|
-
private
|
9
|
-
|
10
8
|
def capacity_iteration
|
11
9
|
words = []
|
12
10
|
capacity_words = words_in_capacity(@current_capacity)
|
@@ -15,25 +13,25 @@ module NumbersAndWords
|
|
15
13
|
words
|
16
14
|
end
|
17
15
|
|
18
|
-
def one?
|
19
|
-
words_in_capacity(@current_capacity) == [translations.ones(1)]
|
20
|
-
end
|
21
|
-
|
22
|
-
def thousand?
|
23
|
-
FiguresArray::THOUSAND_CAPACITY == @current_capacity
|
24
|
-
end
|
25
|
-
|
26
16
|
def hundreds
|
27
17
|
super({ only_hundreds: figures[0, 2] == [0, 0] })
|
28
18
|
end
|
29
19
|
|
30
20
|
def megs
|
31
|
-
prefix = if @figures.hundreds || @figures.tens || @figures.ones
|
32
|
-
:partials
|
33
|
-
end
|
21
|
+
prefix = (:partials if @figures.hundreds || @figures.tens || @figures.ones)
|
34
22
|
|
35
23
|
super(prefix: prefix)
|
36
24
|
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def one?
|
29
|
+
words_in_capacity(@current_capacity) == [translations.ones(1)]
|
30
|
+
end
|
31
|
+
|
32
|
+
def thousand?
|
33
|
+
FiguresArray::THOUSAND_CAPACITY == @current_capacity
|
34
|
+
end
|
37
35
|
end
|
38
36
|
end
|
39
37
|
end
|
@@ -1,12 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module NumbersAndWords
|
2
4
|
module Strategies
|
3
5
|
module FiguresConverter
|
4
6
|
module Languages
|
5
7
|
class Lt < Base
|
6
|
-
include Families::Latin
|
7
|
-
|
8
|
-
private
|
9
|
-
|
10
8
|
def capacity_iteration
|
11
9
|
words = []
|
12
10
|
capacity_words = words_in_capacity(@current_capacity)
|
@@ -15,6 +13,12 @@ module NumbersAndWords
|
|
15
13
|
words
|
16
14
|
end
|
17
15
|
|
16
|
+
def megs
|
17
|
+
super({ number: @figures.number_in_capacity(@current_capacity) })
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
18
22
|
def one?
|
19
23
|
words_in_capacity(@current_capacity) == [translations.ones(1)]
|
20
24
|
end
|
@@ -22,14 +26,6 @@ module NumbersAndWords
|
|
22
26
|
def thousand?
|
23
27
|
FiguresArray::THOUSAND_CAPACITY == @current_capacity
|
24
28
|
end
|
25
|
-
|
26
|
-
def hundreds
|
27
|
-
super({ is_hundred: (figures[1, 2] == [0, 1] && simple_number_to_words.empty?) })
|
28
|
-
end
|
29
|
-
|
30
|
-
def megs
|
31
|
-
super({ number: @figures.number_in_capacity(@current_capacity) })
|
32
|
-
end
|
33
29
|
end
|
34
30
|
end
|
35
31
|
end
|
@@ -1,22 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module NumbersAndWords
|
2
4
|
module Strategies
|
3
5
|
module FiguresConverter
|
4
6
|
module Languages
|
5
7
|
class Lv < Base
|
6
|
-
|
7
|
-
|
8
|
-
private
|
9
|
-
|
10
|
-
def capacity_iteration
|
11
|
-
words = []
|
12
|
-
capacity_words = words_in_capacity(@current_capacity)
|
13
|
-
words.push(megs) unless capacity_words.empty?
|
14
|
-
words += capacity_words
|
15
|
-
words
|
16
|
-
end
|
17
|
-
|
18
|
-
def hundreds
|
19
|
-
super({ is_hundred: (figures[1, 2] == [0, 1] && simple_number_to_words.empty?) })
|
8
|
+
def tens_with_ones
|
9
|
+
super separator: ' '
|
20
10
|
end
|
21
11
|
|
22
12
|
def megs
|
@@ -1,20 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module NumbersAndWords
|
2
4
|
module Strategies
|
3
5
|
module FiguresConverter
|
4
6
|
module Languages
|
5
7
|
class Nl < Base
|
6
|
-
include Families::Latin
|
7
|
-
|
8
8
|
def hundreds_number_to_words
|
9
9
|
[super.reverse.join]
|
10
10
|
end
|
11
11
|
|
12
12
|
def capacity_iteration
|
13
13
|
if FiguresArray::THOUSAND_CAPACITY == @current_capacity
|
14
|
-
words = []
|
15
14
|
capacity_words = words_in_capacity(@current_capacity)
|
16
|
-
|
17
|
-
capacity_words.empty? ? [] : [capacity_words, words].join
|
15
|
+
capacity_words.empty? ? [] : [capacity_words, megs].join
|
18
16
|
else
|
19
17
|
super
|
20
18
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module NumbersAndWords
|
2
4
|
module Strategies
|
3
5
|
module FiguresConverter
|
4
6
|
module Languages
|
5
7
|
class PtBr < Base
|
6
|
-
include Families::Latin
|
7
|
-
|
8
8
|
%i[teens tens tens_with_ones].each do |method_name|
|
9
9
|
define_method(method_name) do
|
10
10
|
super(internal_options)
|
@@ -39,7 +39,7 @@ module NumbersAndWords
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def megs
|
42
|
-
super(internal_options.merge(
|
42
|
+
super(internal_options.merge(number: @figures.number_in_capacity(@current_capacity),
|
43
43
|
is_opaque: opaque?,
|
44
44
|
is_without_connector: without_connector?,
|
45
45
|
is_with_comma: with_comma?))
|
@@ -58,8 +58,7 @@ module NumbersAndWords
|
|
58
58
|
def gender
|
59
59
|
return (options.gender.result || :male) if maybe_ordinal
|
60
60
|
|
61
|
-
|
62
|
-
if @current_capacity > 0 && figures[0] == 1
|
61
|
+
if current_capacity&.positive? && figures[0] == 1
|
63
62
|
:male
|
64
63
|
else
|
65
64
|
options.gender.result
|
@@ -79,22 +78,25 @@ module NumbersAndWords
|
|
79
78
|
end
|
80
79
|
|
81
80
|
def one_thousand?
|
82
|
-
current_capacity == 1 &&
|
81
|
+
current_capacity == 1 &&
|
82
|
+
figures.ones == 1 &&
|
83
|
+
figures.tens.nil? &&
|
84
|
+
figures.hundreds.nil?
|
83
85
|
end
|
84
86
|
|
85
87
|
def without_connector?
|
86
88
|
return false if with_comma?
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
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
|
+
|
93
94
|
false
|
94
95
|
end
|
95
96
|
|
96
97
|
def with_comma?
|
97
98
|
return false unless @current_capacity > 1
|
99
|
+
|
98
100
|
# if any lower capacity is single word, in portuguese only tens are single words
|
99
101
|
number_under_capacity = figures.number_under_capacity(@current_capacity)
|
100
102
|
return false if number_under_capacity < 20
|