numbers_and_words 0.11.3 → 0.11.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 61c568842b41f624cae36c4bdb5648667bd03fb4
4
- data.tar.gz: 9e5179969bd71542b5049171eff600ca785013dd
3
+ metadata.gz: 2f6672607ef61331dcab2560613f0983f852e521
4
+ data.tar.gz: caff72eea42948c2e55ecec50061eec8a9dfba34
5
5
  SHA512:
6
- metadata.gz: 2d94f84e06d4f34094f0d1d034bfac68bce598f60c1fa0b7613eef49ead313d401e3a124e3e3bc1a4680aed936270dba1316bb9e3cfdf5849251b8562646b34a
7
- data.tar.gz: 58cce919fac2b0f9a2efcabec8d35a6bd6ebf1f19503aeba6781bddb25ab90704438064150f604d9bfcd8665a981cfeec81d1e31ee89c54bdb6e1d585c134632
6
+ metadata.gz: 2d762972288f8b5213c880eab4d2d13bf2183f017e4955d5edc5373923e6aaf1e9e1685232e981fd4e0725151cd13d90dd314d04986e15e6d8516fd3d82981f2
7
+ data.tar.gz: f6e50fc911f8e55db858e17bcd653bfdfbc99952fa5f2965e80efff59c0b949dca1992389c802c881d2e702e138f2072c34101c1958fbb7e9ac8c86f06cef43f
@@ -39,6 +39,7 @@ Converte números em letras utilizando a biblioteca I18n.
39
39
  * Česky [cs]
40
40
  * Português [pt]
41
41
  * Português Brasileiro [pt-BR]
42
+ * հայերեն (Armenian) [hy]
42
43
 
43
44
  ** Experimental
44
45
 
@@ -85,6 +86,9 @@ Converte números em letras utilizando a biblioteca I18n.
85
86
  I18n.with_locale(:vi) { 42.to_words }
86
87
  => "bốn mươi hai"
87
88
 
89
+ I18n.with_locale(:hy) { 42.to_words }
90
+ => "քառասուն երկու"
91
+
88
92
  21.to_words
89
93
  => "twenty-one"
90
94
  => "veintiuno"
@@ -104,6 +108,7 @@ Converte números em letras utilizando a biblioteca I18n.
104
108
  => "dvacetjedna"
105
109
  => "vinte e um"
106
110
  => "hai mươi mốt"
111
+ => "քսան մեկ"
107
112
 
108
113
  231.to_words
109
114
  => "two hundred thirty-one"
@@ -124,6 +129,7 @@ Converte números em letras utilizando a biblioteca I18n.
124
129
  => "dvě stě třicetjedna"
125
130
  => "duzentos e trinta e um"
126
131
  => "hai trăm ba mươi mốt"
132
+ => "երկու հարյուր երեսուն մեկ"
127
133
 
128
134
  4030.to_words
129
135
  => "four thousand thirty"
@@ -143,6 +149,7 @@ Converte números em letras utilizando a biblioteca I18n.
143
149
  => "fyra tusen trettio"
144
150
  => "čtyři tisíce třicet"
145
151
  => "bốn nghìn không trăm ba mươi"
152
+ => "չորս հազար երեսուն"
146
153
 
147
154
  1000100.to_words
148
155
  => "one million one hundred"
@@ -162,6 +169,7 @@ Converte números em letras utilizando a biblioteca I18n.
162
169
  => "en miljoner en hundra"
163
170
  => "jeden milión jedno sto"
164
171
  => "một triệu một trăm"
172
+ => "միլիոն հարյուր"
165
173
 
166
174
  1000000000000000000000000000000000.to_words
167
175
  => "one decillion"
@@ -192,6 +200,7 @@ Converte números em letras utilizando a biblioteca I18n.
192
200
  => ["ერთი", "ორი", "სამი"]
193
201
  => ["jedna", "dva", "tři"]
194
202
  => ["một", "hai", "ba"]
203
+ => ["մեկ", "երկու", "երեք"]
195
204
 
196
205
  [11, 22, 133].to_words
197
206
  => ["eleven", "twenty-two", "one hundred thirty-three"]
@@ -211,6 +220,7 @@ Converte números em letras utilizando a biblioteca I18n.
211
220
  => ["elva", "tjugo-två", "en hundra trettio-tre"]
212
221
  => ["jedenáct", "dvacetdva", "jedno sto třicettři"]
213
222
  => ["mười một", "hai mươi hai", "một trăm ba mươi ba"]
223
+ => ["տասնմեկ", "քսան երկու", "հարյուր երեսուն երեք"]
214
224
 
215
225
  21.77.to_words
216
226
  => "twenty-one and seventy-seven hundredths"
@@ -0,0 +1,7 @@
1
+ hy:
2
+ numbers:
3
+ ones: [զրո, մեկ, երկու, երեք, չորս, հինգ, վեց, յոթ, ութ, ինը]
4
+ teens: [_, տասնմեկ, տասներկու, տասներեք, տասնչորս, տասնհինգ, տասնվեց, տասնյոթ, տասնութ, տասնինը]
5
+ tens: [_, տասը, քսան, երեսուն, քառասուն, հիսուն, վաթսուն, յոթանասուն, ութսուն, իննսուն]
6
+ hundreds: հարյուր
7
+ mega: [_, հազար, միլիոն, միլիարդ, տրիլիոն, քառակուսի]
@@ -4,28 +4,31 @@ module NumbersAndWords
4
4
  module Cs
5
5
  module_function
6
6
 
7
- RULE = lambda do |n|
8
- if one_conditions(n)
7
+ RULE = lambda do |number|
8
+ if one_conditions(number)
9
9
  :one
10
- elsif few_conditions(n)
10
+ elsif few_conditions(number)
11
11
  :few
12
- elsif many_conditions(n)
12
+ elsif many_conditions(number)
13
13
  :many
14
14
  else
15
15
  :other
16
16
  end
17
17
  end
18
18
 
19
- def one_conditions(n)
20
- n % 10 == 1 && n % 100 != 11
19
+ def one_conditions(number)
20
+ number % 10 == 1 && number % 100 != 11
21
21
  end
22
22
 
23
- def few_conditions(n)
24
- [2, 3, 4].include?(n % 10) && ![12, 13, 14].include?(n % 100)
23
+ def few_conditions(number)
24
+ [2, 3, 4].include?(number % 10) &&
25
+ ![12, 13, 14].include?(number % 100)
25
26
  end
26
27
 
27
- def many_conditions(n)
28
- (n % 10).zero? || [5, 6, 7, 8, 9].include?(n % 10) || [11, 12, 13, 14].include?(n % 100)
28
+ def many_conditions(number)
29
+ (number % 10).zero? ||
30
+ [5, 6, 7, 8, 9].include?(number % 10) ||
31
+ [11, 12, 13, 14].include?(number % 100)
29
32
  end
30
33
  end
31
34
  end
@@ -4,10 +4,10 @@ module NumbersAndWords
4
4
  module Fr
5
5
  module_function
6
6
 
7
- RULE = ->(n) { one_conditions(n) ? :one : :other }
7
+ RULE = ->(number) { one_conditions(number) ? :one : :other }
8
8
 
9
- def one_conditions(n)
10
- n % 10 == 1 && n % 100 != 11
9
+ def one_conditions(number)
10
+ number % 10 == 1 && number % 100 != 11
11
11
  end
12
12
  end
13
13
  end
@@ -4,22 +4,23 @@ module NumbersAndWords
4
4
  module Lt
5
5
  module_function
6
6
 
7
- RULE = lambda do |n|
8
- if one_conditions(n)
7
+ RULE = lambda do |number|
8
+ if one_conditions(number)
9
9
  :one
10
- elsif ones_conditions(n)
10
+ elsif ones_conditions(number)
11
11
  :ones
12
12
  else
13
13
  :other
14
14
  end
15
15
  end
16
16
 
17
- def one_conditions(n)
18
- n % 10 == 1 && n % 100 != 11
17
+ def one_conditions(number)
18
+ number % 10 == 1 && number % 100 != 11
19
19
  end
20
20
 
21
- def ones_conditions(n)
22
- [2, 3, 4, 5, 6, 7, 8, 9].include?(n % 10) && ![12, 13, 14, 15, 16, 17, 18, 19].include?(n % 100)
21
+ def ones_conditions(number)
22
+ [2, 3, 4, 5, 6, 7, 8, 9].include?(number % 10) &&
23
+ ![12, 13, 14, 15, 16, 17, 18, 19].include?(number % 100)
23
24
  end
24
25
  end
25
26
  end
@@ -4,10 +4,10 @@ module NumbersAndWords
4
4
  module Lv
5
5
  module_function
6
6
 
7
- RULE = ->(n) { one_conditions(n) ? :one : :other }
7
+ RULE = ->(number) { one_conditions(number) ? :one : :other }
8
8
 
9
- def one_conditions(n)
10
- n % 10 == 1 && n % 100 != 11
9
+ def one_conditions(number)
10
+ number % 10 == 1 && number % 100 != 11
11
11
  end
12
12
  end
13
13
  end
@@ -4,28 +4,31 @@ module NumbersAndWords
4
4
  module Ru
5
5
  module_function
6
6
 
7
- RULE = lambda do |n|
8
- if one_conditions(n)
7
+ RULE = lambda do |number|
8
+ if one_conditions(number)
9
9
  :one
10
- elsif few_conditions(n)
10
+ elsif few_conditions(number)
11
11
  :few
12
- elsif many_conditions(n)
12
+ elsif many_conditions(number)
13
13
  :many
14
14
  else
15
15
  :other
16
16
  end
17
17
  end
18
18
 
19
- def one_conditions(n)
20
- n % 10 == 1 && n % 100 != 11
19
+ def one_conditions(number)
20
+ number % 10 == 1 && number % 100 != 11
21
21
  end
22
22
 
23
- def few_conditions(n)
24
- [2, 3, 4].include?(n % 10) && ![12, 13, 14].include?(n % 100)
23
+ def few_conditions(number)
24
+ [2, 3, 4].include?(number % 10) &&
25
+ ![12, 13, 14].include?(number % 100)
25
26
  end
26
27
 
27
- def many_conditions(n)
28
- (n % 10).zero? || [5, 6, 7, 8, 9].include?(n % 10) || [11, 12, 13, 14].include?(n % 100)
28
+ def many_conditions(number)
29
+ (number % 10).zero? ||
30
+ [5, 6, 7, 8, 9].include?(number % 10) ||
31
+ [11, 12, 13, 14].include?(number % 100)
29
32
  end
30
33
  end
31
34
  end
@@ -19,6 +19,7 @@ require 'numbers_and_words/strategies/figures_converter/languages/pt-BR'
19
19
  require 'numbers_and_words/strategies/figures_converter/languages/pt'
20
20
  require 'numbers_and_words/strategies/figures_converter/languages/se'
21
21
  require 'numbers_and_words/strategies/figures_converter/languages/tr'
22
+ require 'numbers_and_words/strategies/figures_converter/languages/hy'
22
23
 
23
24
  require 'numbers_and_words/strategies/figures_converter/languages/families/cyrillic'
24
25
  require 'numbers_and_words/strategies/figures_converter/languages/ru'
@@ -0,0 +1,27 @@
1
+ module NumbersAndWords
2
+ module Strategies
3
+ module FiguresConverter
4
+ module Languages
5
+ class Hy < Base
6
+ def capacity_iteration
7
+ words = []
8
+ capacity_words = words_in_capacity(@current_capacity)
9
+ words.push(megs) unless capacity_words.empty?
10
+ words += capacity_words unless thousand? && one?
11
+ words
12
+ end
13
+
14
+ private
15
+
16
+ def one?
17
+ words_in_capacity(@current_capacity) == [translations.ones(1)]
18
+ end
19
+
20
+ def thousand?
21
+ FiguresArray::THOUSAND_CAPACITY <= @current_capacity
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -16,9 +16,7 @@ module NumbersAndWords
16
16
  end
17
17
 
18
18
  def megs
19
- prefix = if @figures.hundreds || @figures.tens || @figures.ones
20
- :partials
21
- end
19
+ prefix = (:partials if @figures.hundreds || @figures.tens || @figures.ones)
22
20
 
23
21
  super(prefix: prefix)
24
22
  end
@@ -82,12 +82,10 @@ module NumbersAndWords
82
82
 
83
83
  def without_connector?
84
84
  return false if with_comma?
85
- # without connector when there is hundreds and tens_with_ones
86
- return true if figures.hundreds && figures.tens_with_ones
87
- # without connector when there is hundreds and tens
88
- return true if figures.hundreds && figures.tens
89
- # without connector when there is hundreds and ones
90
- return true if figures.hundreds && figures.ones
85
+ return true if figures.hundreds &&
86
+ (figures.tens_with_ones ||
87
+ figures.tens ||
88
+ figures.ones)
91
89
  false
92
90
  end
93
91
 
@@ -22,7 +22,7 @@ module NumbersAndWords
22
22
  def method_missing(method_name, *args, &block)
23
23
  Object.const_get(proxy_class_name(method_name)).new self, args, block
24
24
  rescue NameError
25
- return nil
25
+ nil
26
26
  end
27
27
 
28
28
  private
@@ -23,6 +23,7 @@ require 'numbers_and_words/translations/pt-BR'
23
23
  require 'numbers_and_words/translations/ka'
24
24
  require 'numbers_and_words/translations/cs'
25
25
  require 'numbers_and_words/translations/vi'
26
+ require 'numbers_and_words/translations/hy'
26
27
 
27
28
  module NumbersAndWords
28
29
  module Translations
@@ -0,0 +1,19 @@
1
+ module NumbersAndWords
2
+ module Translations
3
+ class Hy < Base
4
+ include NumbersAndWords::Translations::Families::Latin
5
+
6
+ def tens_with_ones(numbers, options = {})
7
+ options[:separator] ||= ''
8
+ super
9
+ end
10
+
11
+ def hundreds(number, _options = {})
12
+ parts = [t(:hundreds)]
13
+ parts.unshift(t(:ones)[number]) if number > 1
14
+
15
+ parts.join(' ')
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module NumbersAndWords
2
- VERSION = '0.11.3'.freeze
2
+ VERSION = '0.11.4'.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.3
4
+ version: 0.11.4
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-12-03 00:00:00.000000000 Z
11
+ date: 2018-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -81,6 +81,7 @@ files:
81
81
  - lib/numbers_and_words/i18n/locales/numbers.et.yml
82
82
  - lib/numbers_and_words/i18n/locales/numbers.fr.yml
83
83
  - lib/numbers_and_words/i18n/locales/numbers.hu.yml
84
+ - lib/numbers_and_words/i18n/locales/numbers.hy.yml
84
85
  - lib/numbers_and_words/i18n/locales/numbers.it.yml
85
86
  - lib/numbers_and_words/i18n/locales/numbers.ka.yml
86
87
  - lib/numbers_and_words/i18n/locales/numbers.lt.yml
@@ -172,6 +173,7 @@ files:
172
173
  - lib/numbers_and_words/strategies/figures_converter/languages/families/helpers.rb
173
174
  - lib/numbers_and_words/strategies/figures_converter/languages/fr.rb
174
175
  - lib/numbers_and_words/strategies/figures_converter/languages/hu.rb
176
+ - lib/numbers_and_words/strategies/figures_converter/languages/hy.rb
175
177
  - lib/numbers_and_words/strategies/figures_converter/languages/it.rb
176
178
  - lib/numbers_and_words/strategies/figures_converter/languages/ka.rb
177
179
  - lib/numbers_and_words/strategies/figures_converter/languages/lt.rb
@@ -229,6 +231,7 @@ files:
229
231
  - lib/numbers_and_words/translations/families/latin.rb
230
232
  - lib/numbers_and_words/translations/fr.rb
231
233
  - lib/numbers_and_words/translations/hu.rb
234
+ - lib/numbers_and_words/translations/hy.rb
232
235
  - lib/numbers_and_words/translations/it.rb
233
236
  - lib/numbers_and_words/translations/ka.rb
234
237
  - lib/numbers_and_words/translations/lt.rb
@@ -265,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
265
268
  version: '0'
266
269
  requirements: []
267
270
  rubyforge_project:
268
- rubygems_version: 2.6.13
271
+ rubygems_version: 2.6.14
269
272
  signing_key:
270
273
  specification_version: 4
271
274
  summary: Convert numbers to words using I18N.