numbers_and_words 0.10.0 → 0.10.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +6 -14
  2. data/CHANGELOG.md +167 -0
  3. data/README.rdoc +22 -10
  4. data/lib/numbers_and_words/helper_classes/array_extensions/helpers.rb +0 -8
  5. data/lib/numbers_and_words/i18n/locales/numbers.en.yml +16 -4
  6. data/lib/numbers_and_words/i18n/locales/numbers.es.yml +6 -6
  7. data/lib/numbers_and_words/i18n/locales/numbers.fr.yml +13 -12
  8. data/lib/numbers_and_words/i18n/locales/numbers.hu.yml +0 -1
  9. data/lib/numbers_and_words/i18n/locales/numbers.ka.yml +23 -0
  10. data/lib/numbers_and_words/i18n/locales/numbers.lt.yml +10 -10
  11. data/lib/numbers_and_words/i18n/locales/numbers.lv.yml +3 -3
  12. data/lib/numbers_and_words/i18n/locales/numbers.pt.yml +13 -0
  13. data/lib/numbers_and_words/i18n/pluralization.rb +0 -1
  14. data/lib/numbers_and_words/i18n/plurals/fr.rb +1 -1
  15. data/lib/numbers_and_words/strategies/figures_converter/languages.rb +2 -0
  16. data/lib/numbers_and_words/strategies/figures_converter/languages/en.rb +16 -0
  17. data/lib/numbers_and_words/strategies/figures_converter/languages/es.rb +14 -5
  18. data/lib/numbers_and_words/strategies/figures_converter/languages/ka.rb +43 -0
  19. data/lib/numbers_and_words/strategies/figures_converter/languages/lv.rb +1 -9
  20. data/lib/numbers_and_words/strategies/figures_converter/languages/pt.rb +30 -0
  21. data/lib/numbers_and_words/strategies/figures_converter/languages/tr.rb +18 -0
  22. data/lib/numbers_and_words/strategies/figures_converter/options/en.rb +2 -1
  23. data/lib/numbers_and_words/strategies/figures_converter/options/en/pronounced.rb +76 -0
  24. data/lib/numbers_and_words/strategies/figures_converter/options/en_gb.rb +1 -0
  25. data/lib/numbers_and_words/strategies/figures_converter/options/en_gb/pronounced.rb +12 -0
  26. data/lib/numbers_and_words/translations.rb +2 -0
  27. data/lib/numbers_and_words/translations/es.rb +6 -1
  28. data/lib/numbers_and_words/translations/et.rb +1 -5
  29. data/lib/numbers_and_words/translations/hu.rb +0 -4
  30. data/lib/numbers_and_words/translations/ka.rb +72 -0
  31. data/lib/numbers_and_words/translations/pt.rb +27 -0
  32. data/lib/numbers_and_words/translations/tr.rb +9 -0
  33. data/lib/numbers_and_words/version.rb +1 -1
  34. data/lib/numbers_and_words/wrappers/float.rb +1 -9
  35. metadata +25 -16
  36. data/lib/numbers_and_words/i18n/plurals/es.rb +0 -11
@@ -0,0 +1,72 @@
1
+ module NumbersAndWords
2
+ module Translations
3
+ class Ka < Base
4
+ include NumbersAndWords::Translations::Families::Latin
5
+ TENS_VIGESIMAL_RANGES = [
6
+ {
7
+ range: Range.new(0, 4, true),
8
+ name: :twenty,
9
+ multiplicative: 2
10
+ },
11
+ {
12
+ range: Range.new(0, 6, true),
13
+ name: :forty,
14
+ multiplicative: 4
15
+ },
16
+ {
17
+ range: Range.new(0, 8, true),
18
+ name: :sixty,
19
+ multiplicative: 6
20
+ },
21
+ {
22
+ range: Range.new(0, 9, false),
23
+ name: :eighty,
24
+ multiplicative: 8
25
+ },
26
+ ]
27
+
28
+ def vigesimal_range number
29
+ range = nil
30
+ TENS_VIGESIMAL_RANGES.each do|item|
31
+ if item[:range].include? number
32
+ range = item
33
+ break
34
+ end
35
+ end
36
+
37
+ range
38
+ end
39
+
40
+ def tens_with_ones numbers, options = {}
41
+ range = vigesimal_range(numbers[1])
42
+
43
+ if numbers[1] - range[:multiplicative] > 0
44
+ minor = teens(numbers)
45
+ else
46
+ minor = ones(numbers[0])
47
+ end
48
+
49
+ [t([:partials, range[:name]].join('.')), minor].join ''
50
+ end
51
+
52
+ def hundreds number, options = {}
53
+ options[:prefix] ||= (options[:only_hundreds] == true) ? nil : :partials
54
+
55
+ parts = [t([options[:prefix], :one_hundred].join('.'))]
56
+ parts.unshift(ones(number, prefix: :partials)) if number > 1
57
+
58
+ parts.join ''
59
+ end
60
+
61
+ def megs capacity, options = {}
62
+ if capacity == 1
63
+ t([options[:prefix], :one_thousand].join('.'))
64
+ elsif capacity == 2
65
+ t([options[:prefix], :one_million].join('.'))
66
+ elsif capacity == 3
67
+ t([options[:prefix], :one_billion].join('.'))
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,27 @@
1
+ module NumbersAndWords
2
+ module Translations
3
+ class Pt < Base
4
+ include NumbersAndWords::Translations::Families::Latin
5
+
6
+ def tens numbers, options = {}
7
+ options[:alone] = true if options[:alone].nil?
8
+ options[:alone] ? super(numbers) : "#{t(:union)} " + super(numbers)
9
+ end
10
+
11
+ def tens_with_ones numbers, options = {}
12
+ [tens(numbers[1]), " #{t(:union)} ", ones(numbers[0])].join
13
+ end
14
+
15
+ def hundreds number, options = {}
16
+ return t(:one_hundred) if options[:is_one_hundred]
17
+ options[:is_hundred] ? t(:hundreds)[number - 1] : t(:hundreds)[number - 1] + ' e'
18
+ end
19
+
20
+ def megs capacity, options = {}
21
+ options[:is_one] = false if options[:is_one].nil?
22
+ options[:is_one] ? t(:mega)[capacity] : t(:megas)[capacity]
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -6,6 +6,15 @@ module NumbersAndWords
6
6
  def tens_with_ones numbers, options = {}
7
7
  super numbers, :separator => ' '
8
8
  end
9
+
10
+ def hundreds number, options = {}
11
+ if number == 1
12
+ [t([options[:prefix], :hundreds].join('.'))].join options[:separator] || ' '
13
+ else
14
+ [t(:ones)[number], t([options[:prefix], :hundreds].join('.'))].join options[:separator] || ' '
15
+ end
16
+ end
17
+
9
18
  end
10
19
  end
11
20
  end
@@ -1,3 +1,3 @@
1
1
  module NumbersAndWords
2
- VERSION = '0.10.0'
2
+ VERSION = '0.10.5'
3
3
  end
@@ -20,10 +20,6 @@ module NumbersAndWords
20
20
  number.to_s.split '.'
21
21
  end
22
22
 
23
- def exponential?
24
- number.to_s =~ /[eE]{1}\+/
25
- end
26
-
27
23
  def integral_part
28
24
  parts.first
29
25
  end
@@ -48,13 +44,9 @@ module NumbersAndWords
48
44
  {:fractional => {:length => fractional_part.length}}
49
45
  end
50
46
 
51
- def integral_part_is_nil?
52
- 0 == integral_part.to_i
53
- end
54
-
55
47
  def fractional_part_is_nil?
56
48
  0 == fractional_part.to_i
57
49
  end
58
50
  end
59
51
  end
60
- end
52
+ end
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: numbers_and_words
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Lazarev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-03 00:00:00.000000000 Z
11
+ date: 2016-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: jeweler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: Convert numbers to words using I18N.
@@ -71,9 +71,13 @@ email: k.s.lazarev@gmail.com
71
71
  executables: []
72
72
  extensions: []
73
73
  extra_rdoc_files:
74
+ - CHANGELOG.md
74
75
  - LICENSE.txt
75
76
  - README.rdoc
76
77
  files:
78
+ - CHANGELOG.md
79
+ - LICENSE.txt
80
+ - README.rdoc
77
81
  - lib/numbers_and_words.rb
78
82
  - lib/numbers_and_words/core_ext.rb
79
83
  - lib/numbers_and_words/core_ext/array.rb
@@ -94,15 +98,16 @@ files:
94
98
  - lib/numbers_and_words/i18n/locales/numbers.fr.yml
95
99
  - lib/numbers_and_words/i18n/locales/numbers.hu.yml
96
100
  - lib/numbers_and_words/i18n/locales/numbers.it.yml
101
+ - lib/numbers_and_words/i18n/locales/numbers.ka.yml
97
102
  - lib/numbers_and_words/i18n/locales/numbers.lt.yml
98
103
  - lib/numbers_and_words/i18n/locales/numbers.lv.yml
99
104
  - lib/numbers_and_words/i18n/locales/numbers.nl.yml
105
+ - lib/numbers_and_words/i18n/locales/numbers.pt.yml
100
106
  - lib/numbers_and_words/i18n/locales/numbers.ru.yml
101
107
  - lib/numbers_and_words/i18n/locales/numbers.se.yml
102
108
  - lib/numbers_and_words/i18n/locales/numbers.tr.yml
103
109
  - lib/numbers_and_words/i18n/locales/numbers.ua.yml
104
110
  - lib/numbers_and_words/i18n/pluralization.rb
105
- - lib/numbers_and_words/i18n/plurals/es.rb
106
111
  - lib/numbers_and_words/i18n/plurals/fr.rb
107
112
  - lib/numbers_and_words/i18n/plurals/lt.rb
108
113
  - lib/numbers_and_words/i18n/plurals/lv.rb
@@ -156,9 +161,11 @@ files:
156
161
  - lib/numbers_and_words/strategies/figures_converter/languages/fr.rb
157
162
  - lib/numbers_and_words/strategies/figures_converter/languages/hu.rb
158
163
  - lib/numbers_and_words/strategies/figures_converter/languages/it.rb
164
+ - lib/numbers_and_words/strategies/figures_converter/languages/ka.rb
159
165
  - lib/numbers_and_words/strategies/figures_converter/languages/lt.rb
160
166
  - lib/numbers_and_words/strategies/figures_converter/languages/lv.rb
161
167
  - lib/numbers_and_words/strategies/figures_converter/languages/nl.rb
168
+ - lib/numbers_and_words/strategies/figures_converter/languages/pt.rb
162
169
  - lib/numbers_and_words/strategies/figures_converter/languages/ru.rb
163
170
  - lib/numbers_and_words/strategies/figures_converter/languages/se.rb
164
171
  - lib/numbers_and_words/strategies/figures_converter/languages/tr.rb
@@ -167,11 +174,13 @@ files:
167
174
  - lib/numbers_and_words/strategies/figures_converter/options/en.rb
168
175
  - lib/numbers_and_words/strategies/figures_converter/options/en/hundreds_with_union.rb
169
176
  - lib/numbers_and_words/strategies/figures_converter/options/en/ordinal.rb
177
+ - lib/numbers_and_words/strategies/figures_converter/options/en/pronounced.rb
170
178
  - lib/numbers_and_words/strategies/figures_converter/options/en/remove_hyphen.rb
171
179
  - lib/numbers_and_words/strategies/figures_converter/options/en/remove_zero.rb
172
180
  - lib/numbers_and_words/strategies/figures_converter/options/en_gb.rb
173
181
  - lib/numbers_and_words/strategies/figures_converter/options/en_gb/hundreds_with_union.rb
174
182
  - lib/numbers_and_words/strategies/figures_converter/options/en_gb/ordinal.rb
183
+ - lib/numbers_and_words/strategies/figures_converter/options/en_gb/pronounced.rb
175
184
  - lib/numbers_and_words/strategies/figures_converter/options/en_gb/remove_hyphen.rb
176
185
  - lib/numbers_and_words/strategies/figures_converter/options/en_gb/remove_zero.rb
177
186
  - lib/numbers_and_words/strategies/figures_converter/options/hu.rb
@@ -194,9 +203,11 @@ files:
194
203
  - lib/numbers_and_words/translations/fr.rb
195
204
  - lib/numbers_and_words/translations/hu.rb
196
205
  - lib/numbers_and_words/translations/it.rb
206
+ - lib/numbers_and_words/translations/ka.rb
197
207
  - lib/numbers_and_words/translations/lt.rb
198
208
  - lib/numbers_and_words/translations/lv.rb
199
209
  - lib/numbers_and_words/translations/nl.rb
210
+ - lib/numbers_and_words/translations/pt.rb
200
211
  - lib/numbers_and_words/translations/ru.rb
201
212
  - lib/numbers_and_words/translations/se.rb
202
213
  - lib/numbers_and_words/translations/tr.rb
@@ -205,8 +216,6 @@ files:
205
216
  - lib/numbers_and_words/wrappers.rb
206
217
  - lib/numbers_and_words/wrappers/float.rb
207
218
  - lib/numbers_and_words/wrappers/integer.rb
208
- - LICENSE.txt
209
- - README.rdoc
210
219
  homepage: http://github.com/kslazarev/numbers_and_words
211
220
  licenses:
212
221
  - MIT
@@ -217,17 +226,17 @@ require_paths:
217
226
  - lib
218
227
  required_ruby_version: !ruby/object:Gem::Requirement
219
228
  requirements:
220
- - - ! '>='
229
+ - - ">="
221
230
  - !ruby/object:Gem::Version
222
231
  version: '0'
223
232
  required_rubygems_version: !ruby/object:Gem::Requirement
224
233
  requirements:
225
- - - ! '>='
234
+ - - ">="
226
235
  - !ruby/object:Gem::Version
227
236
  version: '0'
228
237
  requirements: []
229
238
  rubyforge_project:
230
- rubygems_version: 2.0.7
239
+ rubygems_version: 2.4.8
231
240
  signing_key:
232
241
  specification_version: 4
233
242
  summary: Convert numbers to words using I18N.
@@ -1,11 +0,0 @@
1
- module NumbersAndWords
2
- module I18n
3
- module Plurals
4
- module Es
5
- include Fr
6
-
7
- RULE = Fr::RULE
8
- end
9
- end
10
- end
11
- end