numbers_and_words 0.11.10 → 0.11.11

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
  SHA256:
3
- metadata.gz: 04032d6938d0487167512413e0035cfd44e568ad622c20fc304d80a217556cf9
4
- data.tar.gz: c316187430a6d4930978215f478f34d9973fbe2bf0efa50dd3969652375eab51
3
+ metadata.gz: 8fbb352f4dff4e1515b73e36972350bb7161cf0c5d8f931565da3c9ace866b30
4
+ data.tar.gz: cab2aaac07c83e7f0c19d97f814608083c573ba36840a8499a7d6334875fa5cd
5
5
  SHA512:
6
- metadata.gz: 81f843d717a8b84cb29096e43845201ac5a2a95e63177736df9135520f452badcc01057035500afd65bed7df9bf36cf78a6ad94a5168295e3d43b2597b6d746b
7
- data.tar.gz: 64dc18b49df49650052b3bc2ca1ad895ddbacd4e60cffe7614c76712bd0270a8eb3695e571fe8c31b4fdf801148bf183056a76a1124f831f6b973e5a231bcc15
6
+ metadata.gz: 85b1af1ea9a76b79bbcdcd98fbd57e10eb677d042ac12ab02648e693b77b83ec7551bfc008e3af7c3615e33cd56295cef1f01c5e2ad213adca7e8aef403efc0c
7
+ data.tar.gz: e7334d4acf4752d1974c55ae76f897c91a64a110b44fea55c42d82913a65fa621737617048067a9ae47ba7bea94d2908d3a937297a348339b4494ed39d01cbeb
data/README.rdoc CHANGED
@@ -34,7 +34,7 @@ Deletrea números en varios idiomas utilizando la gema I18n.
34
34
  * Türkçe [tr]
35
35
  * Deutsch** [de]
36
36
  * Italiano** [it]
37
- * Nederlands** [nl]
37
+ * Nederlands [nl]
38
38
  * Swedish** [se]
39
39
  * English (British)** [en-GB]
40
40
  * Česky [cs]
@@ -107,7 +107,7 @@ Deletrea números en varios idiomas utilizando la gema I18n.
107
107
  => "ოცდაერთი"
108
108
  => "einundzwanzig"
109
109
  => "ventiuno"
110
- => "éénentwintig"
110
+ => "eenentwintig"
111
111
  => "tjugo-en"
112
112
  => "dvacetjedna"
113
113
  => "vinte e um"
@@ -129,7 +129,7 @@ Deletrea números en varios idiomas utilizando la gema I18n.
129
129
  => "iki yüz otuz bir"
130
130
  => "zweihunderteinunddreißig"
131
131
  => "2 cento trentauno"
132
- => "tweehonderdéénendertig"
132
+ => "tweehonderdeenendertig"
133
133
  => "två hundra trettio-en"
134
134
  => "dvě stě třicetjedna"
135
135
  => "duzentos e trinta e um"
@@ -226,7 +226,7 @@ Deletrea números en varios idiomas utilizando la gema I18n.
226
226
  => ["on bir", "yirmi iki", "yüz otuz üç"]
227
227
  => ["elf", "zweiundzwanzig", "einhundertdreiunddreißig"]
228
228
  => ["undici", "ventidue", "1 cento trentatre"]
229
- => ["elf", "tweeentwintig", "honderddrieendertig"]
229
+ => ["elf", "tweeëntwintig", "honderddrieëndertig"]
230
230
  => ["elva", "tjugo-två", "en hundra trettio-tre"]
231
231
  => ["jedenáct", "dvacetdva", "jedno sto třicettři"]
232
232
  => ["mười một", "hai mươi hai", "một trăm ba mươi ba"]
@@ -42,6 +42,10 @@ module NumbersAndWords
42
42
  self[0].to_i if self[0].to_i.positive?
43
43
  end
44
44
 
45
+ def only_ones
46
+ ones if !tens && !hundreds
47
+ end
48
+
45
49
  def teens
46
50
  tens_with_ones if tens == 1
47
51
  end
@@ -1,8 +1,10 @@
1
1
  nl:
2
2
  numbers:
3
- ones: [nul, één, twee, drie, vier, vijf, zes, zeven, acht, negen]
3
+ ones: [nul, een, twee, drie, vier, vijf, zes, zeven, acht, negen]
4
+ loose_one: één
4
5
  teens: [_, elf, twaalf, dertien, veertien, vijftien, zestien, zeventien, achttien, negentien]
5
6
  tens: [_, tien, twintig, dertig, veertig, vijftig, zestig, zeventig, tachtig, negentig]
6
7
  hundreds: honderd
7
8
  mega: [_, duizend, miljoen, miljard, biljoen, biljard, triljoen, triljard, septiljoen, octillion, noniljoen, decillion]
8
9
  union: en
10
+ union2or3: ën
@@ -1,13 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- Hash[
4
- NumbersAndWords::I18n::Pluralization.languages.map do |language|
5
- [language.to_sym, {
6
- i18n: {
7
- plural: {
8
- rule: Object.const_get("NumbersAndWords::I18n::Plurals::#{language.split('-').collect(&:capitalize).join}::RULE")
9
- }
3
+ NumbersAndWords::I18n::Pluralization.languages.map do |language|
4
+ [language.to_sym, {
5
+ i18n: {
6
+ plural: {
7
+ rule: Object.const_get("NumbersAndWords::I18n::Plurals::#{language.split('-').collect(&:capitalize).join}::RULE")
10
8
  }
11
- }]
12
- end
13
- ]
9
+ }
10
+ }]
11
+ end.to_h
@@ -10,9 +10,16 @@ module NumbersAndWords
10
10
  end
11
11
 
12
12
  def capacity_iteration
13
- if FiguresArray::THOUSAND_CAPACITY == @current_capacity
14
- capacity_words = words_in_capacity(@current_capacity)
15
- capacity_words.empty? ? [] : [capacity_words, megs].join
13
+ return super if FiguresArray::THOUSAND_CAPACITY != @current_capacity
14
+ return megs if figures.number_in_capacity(@current_capacity) == 1
15
+
16
+ capacity_words = words_in_capacity(@current_capacity)
17
+ capacity_words.empty? ? [] : [capacity_words, megs].join
18
+ end
19
+
20
+ def simple_number_to_words
21
+ if @figures.only_ones && @figures.ones == 1
22
+ [@translations.t(:loose_one)]
16
23
  else
17
24
  super
18
25
  end
@@ -6,7 +6,7 @@ module NumbersAndWords
6
6
  include NumbersAndWords::Translations::Families::Latin
7
7
 
8
8
  def tens_with_ones(numbers, _options = {})
9
- [ones(numbers[0]), tens(numbers[1])].join(union)
9
+ [ones(numbers[0]), tens(numbers[1])].join(union(numbers[0]))
10
10
  end
11
11
 
12
12
  def hundreds(number, _options = {})
@@ -14,6 +14,14 @@ module NumbersAndWords
14
14
 
15
15
  super number, separator: ''
16
16
  end
17
+
18
+ private
19
+
20
+ def union(units)
21
+ return t :union2or3 if [2, 3].include?(units)
22
+
23
+ t :union
24
+ end
17
25
  end
18
26
  end
19
27
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NumbersAndWords
4
- VERSION = '0.11.10'
4
+ VERSION = '0.11.11'
5
5
  end
@@ -16,7 +16,7 @@ module NumbersAndWords
16
16
  private
17
17
 
18
18
  def to_figures_array
19
- number.to_s.split(//).map(&:to_i).to_figures
19
+ number.to_s.chars.map(&:to_i).to_figures
20
20
  end
21
21
  end
22
22
  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.10
4
+ version: 0.11.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Lazarev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-05 00:00:00.000000000 Z
11
+ date: 2021-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -274,7 +274,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
274
274
  - !ruby/object:Gem::Version
275
275
  version: '0'
276
276
  requirements: []
277
- rubygems_version: 3.2.4
277
+ rubygems_version: 3.2.21
278
278
  signing_key:
279
279
  specification_version: 4
280
280
  summary: Spell out numbers in several languages