numbers_and_words 0.11.1 → 0.11.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +41 -0
  3. data/lib/numbers_and_words/i18n/locales/numbers.cs.yml +84 -0
  4. data/lib/numbers_and_words/i18n/locales/numbers.es.yml +2 -2
  5. data/lib/numbers_and_words/i18n/pluralization.rb +1 -0
  6. data/lib/numbers_and_words/i18n/plurals/cs.rb +33 -0
  7. data/lib/numbers_and_words/strategies/array_joiner/languages.rb +1 -0
  8. data/lib/numbers_and_words/strategies/array_joiner/languages/cs.rb +10 -0
  9. data/lib/numbers_and_words/strategies/figures_converter/decorators.rb +1 -0
  10. data/lib/numbers_and_words/strategies/figures_converter/decorators/cs.rb +3 -0
  11. data/lib/numbers_and_words/strategies/figures_converter/decorators/cs/base.rb +12 -0
  12. data/lib/numbers_and_words/strategies/figures_converter/decorators/cs/fractional.rb +38 -0
  13. data/lib/numbers_and_words/strategies/figures_converter/decorators/cs/integral.rb +28 -0
  14. data/lib/numbers_and_words/strategies/figures_converter/languages.rb +1 -0
  15. data/lib/numbers_and_words/strategies/figures_converter/languages/cs.rb +53 -0
  16. data/lib/numbers_and_words/strategies/figures_converter/languages/es.rb +1 -1
  17. data/lib/numbers_and_words/strategies/figures_converter/languages/families/cyrillic.rb +4 -4
  18. data/lib/numbers_and_words/strategies/figures_converter/options.rb +1 -0
  19. data/lib/numbers_and_words/strategies/figures_converter/options/cs.rb +3 -0
  20. data/lib/numbers_and_words/strategies/figures_converter/options/cs/gender.rb +28 -0
  21. data/lib/numbers_and_words/strategies/figures_converter/options/cs/ordinal.rb +26 -0
  22. data/lib/numbers_and_words/strategies/figures_converter/options/cs/remove_zero.rb +28 -0
  23. data/lib/numbers_and_words/strategies/figures_converter/options/en/ordinal.rb +2 -1
  24. data/lib/numbers_and_words/strategies/figures_converter/options/hu/ordinal.rb +2 -1
  25. data/lib/numbers_and_words/translations.rb +1 -0
  26. data/lib/numbers_and_words/translations/cs.rb +73 -0
  27. data/lib/numbers_and_words/translations/es.rb +5 -7
  28. data/lib/numbers_and_words/version.rb +1 -1
  29. metadata +15 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b50a55c2c09583685e41253468a0b3461c8abdc
4
- data.tar.gz: 0cdf8caaadf8489c87525c989cb169a9fd4987ae
3
+ metadata.gz: 99432fdd87f3645a56d6ce0aa7167af06e8b429c
4
+ data.tar.gz: b909e6a544bb97055e37ad5206ab7cc6c37dcea9
5
5
  SHA512:
6
- metadata.gz: a7c2b223dd06568a4537c95c8b732f1bba9a1ca387715eb38c7d8c6c95cd472f15dfcabd84b40a2ddd67edbf47f932d7846c8b6925f7cf4ac0690c10daeda406
7
- data.tar.gz: 56e6a9a53264ebb40db6e4e9bee0a19565a8d1d4e0d37eadd0e7e04d67442bb0dad1d2bb77db272a6cc08d50750fab6616a68491d0f500d078bc61bb761e804f
6
+ metadata.gz: a3c3e5476646cf106cb9f1785afd1eae53719d635ed658d01332d26ec587d5738df28d816708c57b46eb7a875f4292bfaa1c1474ae80584183ede89ca8f41945
7
+ data.tar.gz: 9c3ba5f8931deee4e0a1324d438cc7f1d2f74aa3839eec2ee743a34afa28a9fd4d4de3c5590f2726c45c83ff7d81e264f2bbb78c11f2074afdc39c4fb497f004
data/README.rdoc CHANGED
@@ -36,6 +36,7 @@ Converte números em letras utilizando a biblioteca I18n.
36
36
  * Nederlands** [nl]
37
37
  * Swedish** [se]
38
38
  * English (British)** [en-GB]
39
+ * Česky [cs]
39
40
  * Português [pt]
40
41
  * Português Brasileiro [pt-BR]
41
42
 
@@ -78,6 +79,9 @@ Converte números em letras utilizando a biblioteca I18n.
78
79
  I18n.with_locale(:ka) { 42.to_words }
79
80
  => "ორმოცდაორი"
80
81
 
82
+ I18n.with_locale(:cs) { 42.to_words }
83
+ => "čtyřicetdva"
84
+
81
85
  21.to_words
82
86
  => "twenty-one"
83
87
  => "veintiuno"
@@ -94,6 +98,7 @@ Converte números em letras utilizando a biblioteca I18n.
94
98
  => "ventiuno"
95
99
  => "éénentwintig"
96
100
  => "tjugo-en"
101
+ => "dvacetjedna"
97
102
  => "vinte e um"
98
103
 
99
104
  231.to_words
@@ -112,6 +117,7 @@ Converte números em letras utilizando a biblioteca I18n.
112
117
  => "2 cento trentauno"
113
118
  => "tweehonderdéénendertig"
114
119
  => "två hundra trettio-en"
120
+ => "dvě stě třicetjedna"
115
121
  => "duzentos e trinta e um"
116
122
 
117
123
  4030.to_words
@@ -130,6 +136,7 @@ Converte números em letras utilizando a biblioteca I18n.
130
136
  => "quattro mille trenta"
131
137
  => "vierthousanddertig"
132
138
  => "fyra tusen trettio"
139
+ => "čtyři tisíce třicet"
133
140
 
134
141
  1000100.to_words
135
142
  => "one million one hundred"
@@ -147,6 +154,7 @@ Converte números em letras utilizando a biblioteca I18n.
147
154
  => "uno milione 1 cento"
148
155
  => "één miljoen honderd"
149
156
  => "en miljoner en hundra"
157
+ => "jeden milión jedno sto"
150
158
 
151
159
  1000000000000000000000000000000000.to_words
152
160
  => "one decillion"
@@ -163,6 +171,7 @@ Converte números em letras utilizando a biblioteca I18n.
163
171
  => "uno decillion"
164
172
  => "één decillion"
165
173
  => "en decillion"
174
+ => "decilijon"
166
175
 
167
176
  [1, 2, 3].to_words
168
177
  => ["one", "two", "three"]
@@ -174,6 +183,7 @@ Converte números em letras utilizando a biblioteca I18n.
174
183
  => ["viens", "divi", "trīs"]
175
184
  => ["üks", "kaks", "kolm"]
176
185
  => ["ერთი", "ორი", "სამი"]
186
+ => ["jedna", "dva", "tři"]
177
187
 
178
188
  [11, 22, 133].to_words
179
189
  => ["eleven", "twenty-two", "one hundred thirty-three"]
@@ -191,6 +201,7 @@ Converte números em letras utilizando a biblioteca I18n.
191
201
  => ["undici", "ventidue", "1 cento trentatre"]
192
202
  => ["elf", "tweeentwintig", "honderddrieendertig"]
193
203
  => ["elva", "tjugo-två", "en hundra trettio-tre"]
204
+ => ["jedenáct", "dvacetdva", "jedno sto třicettři"]
194
205
 
195
206
  21.77.to_words
196
207
  => "twenty-one and seventy-seven hundredths"
@@ -254,6 +265,36 @@ Converte números em letras utilizando a biblioteca I18n.
254
265
  I18n.with_locale(:'pt-BR') { 1000000001.to_words gender: :female }
255
266
  => "um bilhão e uma"
256
267
 
268
+ * Czech
269
+
270
+ Change gender form: (gender: [:female || :male || :neuter])
271
+
272
+ I18n.with_locale(:'cs') { 1.to_words gender: :female }
273
+ => "jedna"
274
+
275
+ I18n.with_locale(:'cs') { 1.to_words gender: :male }
276
+ => "jeden"
277
+
278
+ I18n.with_locale(:'cs') { 1.to_words gender: :neuter }
279
+ => "jedno"
280
+
281
+
282
+ Remove 'zero' from integral part of float: (remove_zero: [true || false])
283
+
284
+ I18n.with_locale(:cs) { 0.7.to_words }
285
+ => "nula celých sedm desetin"
286
+
287
+ I18n.with_locale(:cs) { 0.7.to_words remove_zero: true }
288
+ => "sedm desetin"
289
+
290
+ Ordinal form: (ordinal: [true || false])
291
+
292
+ I18n.with_locale(:cs) { 21.to_words ordinal: true }
293
+ => "dvacátý první"
294
+
295
+ I18n.with_locale(:cs) { 21.to_words gender: :female, ordinal: true }
296
+ => "dvacátá první"
297
+
257
298
  == Other options / Другие опции
258
299
 
259
300
  * precision
@@ -0,0 +1,84 @@
1
+ cs:
2
+ numbers:
3
+ union: ''
4
+ union_separator: ''
5
+ integral: celých
6
+ ones:
7
+ male: [nula, jeden, dva, tři, čtyři, pět, šest, sedm, osm, devět]
8
+ female: [nula, jedna, dvě, tři, čtyři, pět, šest, sedm, osm, devět]
9
+ neuter: [nula, jedno, dvě, tři, čtyři, pět, šest, sedm, osm, devět]
10
+ teens: [deset, jedenáct, dvanáct, třináct, čtrnáct, patnáct, šestnáct, sedmnáct, osmnáct, devatenáct]
11
+ tens: [_, deset, dvacet, třicet, čtyřicet, padesát, šedesát, sedmdesát, osmdesát, devadesát]
12
+ hundreds: [_, jedno sto, dvě stě, tři sta, čtyři sta, pět set, šest set, sedm set, osm set, devět set]
13
+ # gem pouziva se deleni po 10^3, http://www.converter.cz/prevody/velka-cisla.htm
14
+ # mega: [ones, thousands, miliony, miliardy, biliony, biliardy, triliony, triliardy, quadriliony, quadriliardy]
15
+ micro:
16
+ one: [_, desetina, setina, tisícina, milióntina, miliardtina, bilióntina]
17
+ few: [_, desetiny, setiny, tisíciny, milióntiny, miliardtiny, bilióntiny]
18
+ many: [_, desetin, setin, tisícin, milióntin, miliardtin, bilióntin]
19
+ sub_micro: [_, deseti, sto]
20
+ thousands:
21
+ one: tisíc
22
+ few: tisíce
23
+ many: tisíc
24
+ millions:
25
+ one: milión
26
+ few: milióny
27
+ many: miliónů
28
+ billions:
29
+ one: miliarda
30
+ few: miliardy
31
+ many: miliard
32
+ trillions:
33
+ one: bilion
34
+ few: biliony
35
+ many: bilionů
36
+ quadrillions:
37
+ one: biliarda
38
+ few: biliardy
39
+ many: biliard
40
+ quintillion:
41
+ one: trilion
42
+ few: triliony
43
+ many: trilionů
44
+ sextillions:
45
+ one: triliarda
46
+ few: triliardy
47
+ many: triliard
48
+ septillions:
49
+ one: kvadrilion
50
+ few: kvadriliony
51
+ many: kvadrilionů
52
+ octillions:
53
+ one: kvadriliarda
54
+ few: kvadriliardy
55
+ many: kvadriliard
56
+ mega:
57
+ - ones
58
+ - thousands
59
+ - millions
60
+ - billions
61
+ - trillions
62
+ - quadrillions
63
+ - quintillion
64
+ - sextillions
65
+ - septillions
66
+ - octillions
67
+ ordinal:
68
+ ones:
69
+ male: [nultý, první, druhý, třetí, čtvrtý, pátý, šestý, sedmý, osmý, devátý]
70
+ female: [nultá, první, druhá, třetí, čtvrtá, pátá, šestá, sedmá, osmá, devátá]
71
+ neuter: [nulté, první, druhé, třetí, čtvrté, páté, šesté, sedmé, osmé, deváté]
72
+ teens:
73
+ male: [desátý, jedenáctý, dvanáctý, třináctý, čtrnáctý, patnáctý, šestnáctý, sedmnáctý, osmnáctý, devatenáctý]
74
+ female: [desátá, jedenáctá, dvanáctá, třináctá, čtrnáctá, patnáctá, šestnáctá, sedmnáctá, osmnáctá, devatenáctá]
75
+ neuter: [desáté, jedenácté, dvanácté, třinácté, čtrnácté, patnácté, šestnácté, sedmnácté, osmnácté, devatenácté]
76
+ tens:
77
+ male: [_, desátý, dvacátý, třicátý, čtyřicátý, padesátý, šedesátý, sedmdesátý, osmdesátý, devadesátý]
78
+ female: [_, desátá, dvacátá, třicátá, čtyřicátá, padesátá, šedesátá, sedmdesátá, osmdesátá, devadesátá]
79
+ neuter: [_, desáté, dvacáté, třicáté, čtyřicáté, padesáté, šedesáté, sedmdesáté, osmdesáté, devadesáté]
80
+ hundreds:
81
+ male: [_, stý, dvoustý, třístý, čtyřstý, pětistý, šestistý, sedmistý, osmistý, devítistý]
82
+ female: [_, stá, dvoustá, třístá, čtyřstá, pětistá, šestistá, sedmistá, osmistá, devítistá]
83
+ neuter: [_, sté, dvousté, třísté, čtyřsté, pětisté, šestisté, sedmisté, osmisté, devítisté]
84
+
@@ -44,7 +44,7 @@ es:
44
44
  one: septillón
45
45
  other: septillones
46
46
  quattuordecillions: mil septillones
47
- union_separator: con
47
+ union: y
48
48
  micro: [_, tenths, hundredths, thousandths, millionths, billionths, trillionths, quadrillionths, quintillionths, sextillionths, septillionths, octillionths, nonillionths, decillionths, undecillionths, duodecillionths, tredecillionths, quattuordecillionths]
49
49
  micro_prefix:
50
50
  tens: diez
@@ -100,4 +100,4 @@ es:
100
100
  quattuordecillionths:
101
101
  one: milseptillonésima
102
102
  other: milseptillonésimas
103
- union: y
103
+ union_separator: con
@@ -1,3 +1,4 @@
1
+ require 'numbers_and_words/i18n/plurals/cs'
1
2
  require 'numbers_and_words/i18n/plurals/ru'
2
3
  require 'numbers_and_words/i18n/plurals/ua'
3
4
  require 'numbers_and_words/i18n/plurals/fr'
@@ -0,0 +1,33 @@
1
+ module NumbersAndWords
2
+ module I18n
3
+ module Plurals
4
+ module Cs
5
+ module_function
6
+
7
+ RULE = lambda do |n|
8
+ if one_conditions(n)
9
+ :one
10
+ elsif few_conditions(n)
11
+ :few
12
+ elsif many_conditions(n)
13
+ :many
14
+ else
15
+ :other
16
+ end
17
+ end
18
+
19
+ def one_conditions(n)
20
+ n % 10 == 1 && n % 100 != 11
21
+ end
22
+
23
+ def few_conditions(n)
24
+ [2, 3, 4].include?(n % 10) && ![12, 13, 14].include?(n % 100)
25
+ end
26
+
27
+ def many_conditions(n)
28
+ (n % 10).zero? || [5, 6, 7, 8, 9].include?(n % 10) || [11, 12, 13, 14].include?(n % 100)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -10,6 +10,7 @@ require 'numbers_and_words/strategies/array_joiner/languages/hu'
10
10
  require 'numbers_and_words/strategies/array_joiner/languages/ru'
11
11
  require 'numbers_and_words/strategies/array_joiner/languages/ua'
12
12
  require 'numbers_and_words/strategies/array_joiner/languages/pt-BR'
13
+ require 'numbers_and_words/strategies/array_joiner/languages/cs'
13
14
 
14
15
  module NumbersAndWords
15
16
  module Strategies
@@ -0,0 +1,10 @@
1
+ module NumbersAndWords
2
+ module Strategies
3
+ module ArrayJoiner
4
+ module Languages
5
+ class Cs < Base
6
+ end
7
+ end
8
+ end
9
+ end
10
+ end
@@ -7,6 +7,7 @@ require 'numbers_and_words/strategies/figures_converter/decorators/ru'
7
7
  require 'numbers_and_words/strategies/figures_converter/decorators/pt-BR'
8
8
  require 'numbers_and_words/strategies/figures_converter/decorators/hu'
9
9
  require 'numbers_and_words/strategies/figures_converter/decorators/ua'
10
+ require 'numbers_and_words/strategies/figures_converter/decorators/cs'
10
11
 
11
12
  module NumbersAndWords
12
13
  module Strategies
@@ -0,0 +1,3 @@
1
+ require 'numbers_and_words/strategies/figures_converter/decorators/cs/base'
2
+ require 'numbers_and_words/strategies/figures_converter/decorators/cs/fractional'
3
+ require 'numbers_and_words/strategies/figures_converter/decorators/cs/integral'
@@ -0,0 +1,12 @@
1
+ module NumbersAndWords
2
+ module Strategies
3
+ module FiguresConverter
4
+ module Decorators
5
+ module Cs
6
+ class Base < Decorators::Base
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,38 @@
1
+ module NumbersAndWords
2
+ module Strategies
3
+ module FiguresConverter
4
+ module Decorators
5
+ module Cs
6
+ class Fractional < Base
7
+ def run
8
+ @options[:gender] = :female
9
+ "#{super} #{fraction_significance}"
10
+ end
11
+
12
+ private
13
+
14
+ def fraction_significance
15
+ @strategy.translations.micros full_fraction.fraction_capacity, figures.reverse.join.to_i
16
+ end
17
+
18
+ def full_fraction
19
+ (0..zero_length).inject(figures.clone) { |result, _el| result.unshift '0' }.to_figures
20
+ end
21
+
22
+ def figures
23
+ @strategy.figures
24
+ end
25
+
26
+ def zero_length
27
+ fraction_length - figures.length
28
+ end
29
+
30
+ def fraction_length
31
+ @options[:fractional][:length].to_i
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,28 @@
1
+ module NumbersAndWords
2
+ module Strategies
3
+ module FiguresConverter
4
+ module Decorators
5
+ module Cs
6
+ class Integral < Base
7
+ def run
8
+ @options[:gender] = :female
9
+ [super, integral_significance].compact.join(' ')
10
+ end
11
+
12
+ private
13
+
14
+ def integral_significance
15
+ figs = figures.reverse.join.to_i
16
+ return nil if @options[:remove_zero] && figs.zero?
17
+ @strategy.translations.integral figs
18
+ end
19
+
20
+ def figures
21
+ @strategy.language.figures
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -25,6 +25,7 @@ require 'numbers_and_words/strategies/figures_converter/languages/ru'
25
25
  require 'numbers_and_words/strategies/figures_converter/languages/ua'
26
26
  require 'numbers_and_words/strategies/figures_converter/languages/pt'
27
27
  require 'numbers_and_words/strategies/figures_converter/languages/pt-BR'
28
+ require 'numbers_and_words/strategies/figures_converter/languages/cs'
28
29
 
29
30
  require 'numbers_and_words/strategies/figures_converter/languages/ka'
30
31
 
@@ -0,0 +1,53 @@
1
+ module NumbersAndWords
2
+ module Strategies
3
+ module FiguresConverter
4
+ module Languages
5
+ class Cs < Base
6
+ include Families::Latin
7
+
8
+ # methods in translations/cs.rb which can work with :gender or :ordinal
9
+ %i[ones teens tens tens_with_ones hundreds].each do |method_name|
10
+ define_method(method_name) do
11
+ super(internal_options)
12
+ end
13
+ end
14
+
15
+ def zero
16
+ super(internal_options) unless maybe_remove_zero
17
+ end
18
+
19
+ def megs(*args)
20
+ super({ number: @figures.number_in_capacity(@current_capacity) }.merge(args.first || {}))
21
+ end
22
+
23
+ def gender
24
+ @current_capacity ||= 0
25
+ # @current_capacity = order of block of 3 digits, backwards (0 = hundreds tens ones)
26
+
27
+ if @current_capacity.zero?
28
+ options.gender.result
29
+ elsif @current_capacity > 2 && @current_capacity.odd?
30
+ :female # miliardy, biliardy, triliardy .....
31
+ else
32
+ :male
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def internal_options
39
+ { gender: gender, prefix: maybe_ordinal }
40
+ end
41
+
42
+ def maybe_remove_zero
43
+ @options.remove_zero.result
44
+ end
45
+
46
+ def maybe_ordinal
47
+ @options.ordinal.result
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -66,7 +66,7 @@ module NumbersAndWords
66
66
  def gender
67
67
  @current_capacity ||= 0
68
68
 
69
- return 'male'.to_sym if @current_capacity >= 2
69
+ return :male if @current_capacity >= 2
70
70
  @options.gender.result
71
71
  end
72
72
 
@@ -20,13 +20,13 @@ module NumbersAndWords
20
20
  end
21
21
 
22
22
  %i[ones tens_with_ones].each do |method_name|
23
- define_method(method_name) do
24
- super({ gender: gender })
23
+ define_method(method_name) do |*args|
24
+ super({ gender: gender }.merge(args.first || {}))
25
25
  end
26
26
  end
27
27
 
28
- def megs
29
- super({ number: @figures.number_in_capacity(@current_capacity) })
28
+ def megs(*args)
29
+ super({ number: @figures.number_in_capacity(@current_capacity) }.merge(args.first || {}))
30
30
  end
31
31
  end
32
32
  end
@@ -5,6 +5,7 @@ require 'numbers_and_words/strategies/figures_converter/options/hu'
5
5
  require 'numbers_and_words/strategies/figures_converter/options/pt-BR'
6
6
  require 'numbers_and_words/strategies/figures_converter/options/ru'
7
7
  require 'numbers_and_words/strategies/figures_converter/options/ua'
8
+ require 'numbers_and_words/strategies/figures_converter/options/cs'
8
9
 
9
10
  module NumbersAndWords
10
11
  module Strategies
@@ -0,0 +1,3 @@
1
+ require 'numbers_and_words/strategies/figures_converter/options/cs/gender'
2
+ require 'numbers_and_words/strategies/figures_converter/options/cs/remove_zero'
3
+ require 'numbers_and_words/strategies/figures_converter/options/cs/ordinal'
@@ -0,0 +1,28 @@
1
+ module NumbersAndWords
2
+ module Strategies
3
+ module FiguresConverter
4
+ module Options
5
+ module Cs
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 : :female
16
+ end
17
+
18
+ private
19
+
20
+ def active?
21
+ @options[:gender]
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,26 @@
1
+ module NumbersAndWords
2
+ module Strategies
3
+ module FiguresConverter
4
+ module Options
5
+ module Cs
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
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,28 @@
1
+ module NumbersAndWords
2
+ module Strategies
3
+ module FiguresConverter
4
+ module Options
5
+ module Cs
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
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -34,7 +34,8 @@ module NumbersAndWords
34
34
 
35
35
  def simple_numbers_condition
36
36
  current_capacity.nil? &&
37
- (HUNDRED_TYPE != @type || (HUNDRED_TYPE == @type && simple_number_to_words.empty?))
37
+ (HUNDRED_TYPE != @type ||
38
+ HUNDRED_TYPE == @type && simple_number_to_words.empty?)
38
39
  end
39
40
 
40
41
  def megs_numbers_condition
@@ -34,7 +34,8 @@ module NumbersAndWords
34
34
 
35
35
  def simple_numbers_condition
36
36
  current_capacity.nil? &&
37
- (HUNDRED_TYPE != @type || (HUNDRED_TYPE == @type && simple_number_to_words.empty?))
37
+ (HUNDRED_TYPE != @type ||
38
+ HUNDRED_TYPE == @type && simple_number_to_words.empty?)
38
39
  end
39
40
 
40
41
  def megs_numbers_condition
@@ -21,6 +21,7 @@ require 'numbers_and_words/translations/de'
21
21
  require 'numbers_and_words/translations/pt'
22
22
  require 'numbers_and_words/translations/pt-BR'
23
23
  require 'numbers_and_words/translations/ka'
24
+ require 'numbers_and_words/translations/cs'
24
25
 
25
26
  module NumbersAndWords
26
27
  module Translations
@@ -0,0 +1,73 @@
1
+ module NumbersAndWords
2
+ module Translations
3
+ class Cs < Base
4
+ include NumbersAndWords::Translations::Families::Base
5
+ include NumbersAndWords::Translations::Extensions::FractionSignificance
6
+
7
+ def zero(options = {})
8
+ ones(0, options)
9
+ end
10
+
11
+ def ones(number, options = {})
12
+ t([options[:prefix], :ones, options[:gender]].join('.'))[number]
13
+ end
14
+
15
+ # for 20, 30, 60
16
+ def tens(number, options = {})
17
+ t([options[:prefix], :tens, gender_to_use(options)].join('.'))[number]
18
+ end
19
+
20
+ # for 12, 13, 19
21
+ def teens(number_arr, options = {})
22
+ t([options[:prefix], :teens, gender_to_use(options)].join('.'))[number_arr.first]
23
+ end
24
+
25
+ # for 42, 23, 69
26
+ def tens_with_ones(numbers_arr, options = {})
27
+ connector = ' '
28
+ [tens(numbers_arr[1], options), connector, ones(numbers_arr[0], options)].join
29
+ end
30
+
31
+ def hundreds(number, options = {})
32
+ t([options[:prefix], :hundreds, gender_to_use(options)].join('.'))[number]
33
+ end
34
+
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
+ def integral(number, _options = {})
46
+ t(:integral, count: number)
47
+ end
48
+
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
+ private
63
+
64
+ def ordinal?(options)
65
+ options[:prefix] == :ordinal
66
+ end
67
+
68
+ def gender_to_use(options)
69
+ ordinal?(options) ? options[:gender] : nil
70
+ end
71
+ end
72
+ end
73
+ end
@@ -10,7 +10,8 @@ module NumbersAndWords
10
10
 
11
11
  def ones(number, options = {})
12
12
  return if options[:is_one_thousand]
13
- return t(%i[ones apocopated].join('.')) if options[:is_apocopated]
13
+ return t(%i[ones apocopated].join('.')) if number == 1 &&
14
+ options[:is_apocopated]
14
15
  t([:ones, options[:gender]].join('.'))[number]
15
16
  end
16
17
 
@@ -20,12 +21,9 @@ module NumbersAndWords
20
21
  end
21
22
 
22
23
  def tens_with_ones(numbers, options = {})
23
- ones_number = if options[:is_apocopated] && numbers[0] == 1
24
- t(%i[ones apocopated].join('.'))
25
- else
26
- t([:ones, options[:gender]].join('.'))[numbers[0]]
27
- end
28
- [tens(numbers[1], alone: false), t(:union), ones_number].join(' ')
24
+ [tens(numbers[1], alone: false),
25
+ t(:union),
26
+ ones(numbers[0], options)].join(' ')
29
27
  end
30
28
 
31
29
  def hundreds(number, options = {})
@@ -1,3 +1,3 @@
1
1
  module NumbersAndWords
2
- VERSION = '0.11.1'.freeze
2
+ VERSION = '0.11.2'.freeze
3
3
  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.1
4
+ version: 0.11.2
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-07-23 00:00:00.000000000 Z
11
+ date: 2017-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -73,6 +73,7 @@ files:
73
73
  - lib/numbers_and_words/helper_classes/words_array.rb
74
74
  - lib/numbers_and_words/i18n.rb
75
75
  - lib/numbers_and_words/i18n/initialization.rb
76
+ - lib/numbers_and_words/i18n/locales/numbers.cs.yml
76
77
  - lib/numbers_and_words/i18n/locales/numbers.de.yml
77
78
  - lib/numbers_and_words/i18n/locales/numbers.en-GB.yml
78
79
  - lib/numbers_and_words/i18n/locales/numbers.en.yml
@@ -92,6 +93,7 @@ files:
92
93
  - lib/numbers_and_words/i18n/locales/numbers.tr.yml
93
94
  - lib/numbers_and_words/i18n/locales/numbers.ua.yml
94
95
  - lib/numbers_and_words/i18n/pluralization.rb
96
+ - lib/numbers_and_words/i18n/plurals/cs.rb
95
97
  - lib/numbers_and_words/i18n/plurals/fr.rb
96
98
  - lib/numbers_and_words/i18n/plurals/lt.rb
97
99
  - lib/numbers_and_words/i18n/plurals/lv.rb
@@ -102,6 +104,7 @@ files:
102
104
  - lib/numbers_and_words/strategies/array_joiner.rb
103
105
  - lib/numbers_and_words/strategies/array_joiner/languages.rb
104
106
  - lib/numbers_and_words/strategies/array_joiner/languages/base.rb
107
+ - lib/numbers_and_words/strategies/array_joiner/languages/cs.rb
105
108
  - lib/numbers_and_words/strategies/array_joiner/languages/en-GB.rb
106
109
  - lib/numbers_and_words/strategies/array_joiner/languages/en.rb
107
110
  - lib/numbers_and_words/strategies/array_joiner/languages/es.rb
@@ -114,6 +117,10 @@ files:
114
117
  - lib/numbers_and_words/strategies/figures_converter.rb
115
118
  - lib/numbers_and_words/strategies/figures_converter/decorators.rb
116
119
  - lib/numbers_and_words/strategies/figures_converter/decorators/base.rb
120
+ - lib/numbers_and_words/strategies/figures_converter/decorators/cs.rb
121
+ - lib/numbers_and_words/strategies/figures_converter/decorators/cs/base.rb
122
+ - lib/numbers_and_words/strategies/figures_converter/decorators/cs/fractional.rb
123
+ - lib/numbers_and_words/strategies/figures_converter/decorators/cs/integral.rb
117
124
  - lib/numbers_and_words/strategies/figures_converter/decorators/en-GB.rb
118
125
  - lib/numbers_and_words/strategies/figures_converter/decorators/en-GB/base.rb
119
126
  - lib/numbers_and_words/strategies/figures_converter/decorators/en-GB/fractional.rb
@@ -148,6 +155,7 @@ files:
148
155
  - lib/numbers_and_words/strategies/figures_converter/decorators/ua/integral.rb
149
156
  - lib/numbers_and_words/strategies/figures_converter/languages.rb
150
157
  - lib/numbers_and_words/strategies/figures_converter/languages/base.rb
158
+ - lib/numbers_and_words/strategies/figures_converter/languages/cs.rb
151
159
  - lib/numbers_and_words/strategies/figures_converter/languages/de.rb
152
160
  - lib/numbers_and_words/strategies/figures_converter/languages/en-GB.rb
153
161
  - lib/numbers_and_words/strategies/figures_converter/languages/en.rb
@@ -171,6 +179,10 @@ files:
171
179
  - lib/numbers_and_words/strategies/figures_converter/languages/tr.rb
172
180
  - lib/numbers_and_words/strategies/figures_converter/languages/ua.rb
173
181
  - lib/numbers_and_words/strategies/figures_converter/options.rb
182
+ - lib/numbers_and_words/strategies/figures_converter/options/cs.rb
183
+ - lib/numbers_and_words/strategies/figures_converter/options/cs/gender.rb
184
+ - lib/numbers_and_words/strategies/figures_converter/options/cs/ordinal.rb
185
+ - lib/numbers_and_words/strategies/figures_converter/options/cs/remove_zero.rb
174
186
  - lib/numbers_and_words/strategies/figures_converter/options/en-GB.rb
175
187
  - lib/numbers_and_words/strategies/figures_converter/options/en-GB/hundreds_with_union.rb
176
188
  - lib/numbers_and_words/strategies/figures_converter/options/en-GB/ordinal.rb
@@ -199,6 +211,7 @@ files:
199
211
  - lib/numbers_and_words/strategies/figures_converter/options/ua/gender.rb
200
212
  - lib/numbers_and_words/translations.rb
201
213
  - lib/numbers_and_words/translations/base.rb
214
+ - lib/numbers_and_words/translations/cs.rb
202
215
  - lib/numbers_and_words/translations/de.rb
203
216
  - lib/numbers_and_words/translations/en-GB.rb
204
217
  - lib/numbers_and_words/translations/en.rb