numbers_and_words 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/README.rdoc +90 -1
- data/lib/numbers_and_words.rb +4 -3
- data/lib/numbers_and_words/core_ext.rb +1 -0
- data/lib/numbers_and_words/core_ext/array.rb +1 -1
- data/lib/numbers_and_words/core_ext/float.rb +5 -0
- data/lib/numbers_and_words/core_ext/integer.rb +2 -9
- data/lib/numbers_and_words/helper_classes.rb +2 -0
- data/lib/numbers_and_words/helper_classes/array_extensions/helpers.rb +81 -0
- data/lib/numbers_and_words/helper_classes/array_extensions/validations.rb +19 -0
- data/lib/numbers_and_words/helper_classes/figures_array.rb +18 -0
- data/lib/numbers_and_words/helper_classes/words_array.rb +11 -0
- data/lib/numbers_and_words/i18n/locales/numbers.en.yml +48 -0
- data/lib/numbers_and_words/i18n/locales/numbers.es.yml +15 -0
- data/lib/numbers_and_words/i18n/locales/numbers.hu.yml +16 -0
- data/lib/numbers_and_words/i18n/locales/numbers.ru.yml +27 -3
- data/lib/numbers_and_words/i18n/locales/numbers.se.yml +7 -0
- data/lib/numbers_and_words/i18n/locales/numbers.ua.yml +14 -2
- data/lib/numbers_and_words/i18n/pluralization.rb +1 -0
- data/lib/numbers_and_words/i18n/plurals/es.rb +11 -0
- data/lib/numbers_and_words/strategies.rb +16 -11
- data/lib/numbers_and_words/strategies/array_joiner.rb +31 -0
- data/lib/numbers_and_words/strategies/figures_converter.rb +33 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators.rb +39 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/base.rb +18 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/en.rb +3 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/en/base.rb +12 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/en/fractional.rb +38 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/en/integral.rb +12 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/hu.rb +3 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/hu/base.rb +12 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/hu/fractional.rb +38 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/hu/integral.rb +12 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ru.rb +3 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ru/base.rb +12 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ru/fractional.rb +39 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ru/integral.rb +27 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ua.rb +3 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ua/base.rb +12 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ua/fractional.rb +39 -0
- data/lib/numbers_and_words/strategies/figures_converter/decorators/ua/integral.rb +27 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages.rb +39 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/base.rb +29 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/en.rb +48 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/es.rb +37 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/families/base.rb +77 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/families/cyrillic.rb +34 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/families/helpers.rb +36 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/families/latin.rb +13 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/fr.rb +37 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/hu.rb +63 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/it.rb +11 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/nl.rb +26 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/ru.rb +11 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/se.rb +11 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/tr.rb +11 -0
- data/lib/numbers_and_words/strategies/figures_converter/languages/ua.rb +11 -0
- data/lib/numbers_and_words/strategies/figures_converter/options.rb +41 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/en.rb +4 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/en/hundreds_with_union.rb +33 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/en/ordinal.rb +60 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/en/remove_hyphen.rb +29 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/en/remove_zero.rb +29 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/hu.rb +1 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/hu/ordinal.rb +60 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ru.rb +1 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ru/gender.rb +28 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ua.rb +1 -0
- data/lib/numbers_and_words/strategies/figures_converter/options/ua/gender.rb +28 -0
- data/lib/numbers_and_words/translations.rb +25 -0
- data/lib/numbers_and_words/{translations_helpers → translations}/base.rb +2 -2
- data/lib/numbers_and_words/translations/en.rb +8 -0
- data/lib/numbers_and_words/translations/es.rb +37 -0
- data/lib/numbers_and_words/translations/extensions/fraction_significance.rb +25 -0
- data/lib/numbers_and_words/translations/families/base.rb +33 -0
- data/lib/numbers_and_words/translations/families/cyrillic.rb +29 -0
- data/lib/numbers_and_words/translations/families/latin.rb +23 -0
- data/lib/numbers_and_words/translations/fr.rb +29 -0
- data/lib/numbers_and_words/translations/hu.rb +26 -0
- data/lib/numbers_and_words/translations/it.rb +15 -0
- data/lib/numbers_and_words/translations/nl.rb +15 -0
- data/lib/numbers_and_words/translations/ru.rb +25 -0
- data/lib/numbers_and_words/translations/se.rb +11 -0
- data/lib/numbers_and_words/translations/tr.rb +11 -0
- data/lib/numbers_and_words/translations/ua.rb +21 -0
- data/lib/numbers_and_words/version.rb +1 -1
- data/lib/numbers_and_words/wrappers.rb +2 -0
- data/lib/numbers_and_words/wrappers/float.rb +60 -0
- data/lib/numbers_and_words/wrappers/integer.rb +21 -0
- metadata +81 -44
- data/lib/numbers_and_words/array_additions.rb +0 -2
- data/lib/numbers_and_words/array_additions/helpers.rb +0 -44
- data/lib/numbers_and_words/array_additions/validations.rb +0 -9
- data/lib/numbers_and_words/figures_array.rb +0 -15
- data/lib/numbers_and_words/strategies/base.rb +0 -18
- data/lib/numbers_and_words/strategies/en.rb +0 -8
- data/lib/numbers_and_words/strategies/families/base.rb +0 -71
- data/lib/numbers_and_words/strategies/families/cyrillic.rb +0 -18
- data/lib/numbers_and_words/strategies/families/latin.rb +0 -9
- data/lib/numbers_and_words/strategies/fr.rb +0 -32
- data/lib/numbers_and_words/strategies/it.rb +0 -8
- data/lib/numbers_and_words/strategies/nl.rb +0 -23
- data/lib/numbers_and_words/strategies/ru.rb +0 -8
- data/lib/numbers_and_words/strategies/tr.rb +0 -8
- data/lib/numbers_and_words/strategies/ua.rb +0 -8
- data/lib/numbers_and_words/translations_helpers.rb +0 -11
- data/lib/numbers_and_words/translations_helpers/en.rb +0 -12
- data/lib/numbers_and_words/translations_helpers/families/base.rb +0 -30
- data/lib/numbers_and_words/translations_helpers/families/cyrillic.rb +0 -28
- data/lib/numbers_and_words/translations_helpers/families/latin.rb +0 -23
- data/lib/numbers_and_words/translations_helpers/fr.rb +0 -34
- data/lib/numbers_and_words/translations_helpers/it.rb +0 -16
- data/lib/numbers_and_words/translations_helpers/nl.rb +0 -18
- data/lib/numbers_and_words/translations_helpers/ru.rb +0 -8
- data/lib/numbers_and_words/translations_helpers/tr.rb +0 -8
- data/lib/numbers_and_words/translations_helpers/ua.rb +0 -8
@@ -1,18 +0,0 @@
|
|
1
|
-
module NumbersAndWords
|
2
|
-
module Strategies
|
3
|
-
module Families
|
4
|
-
module Cyrillic
|
5
|
-
include NumbersAndWords::Strategies::Families::Base
|
6
|
-
|
7
|
-
attr_accessor :current_capacity
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
def words_in_capacity capacity = 0
|
12
|
-
@current_capacity = capacity
|
13
|
-
super
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
module NumbersAndWords
|
2
|
-
module Strategies
|
3
|
-
class Fr < Base
|
4
|
-
include Families::Latin
|
5
|
-
include NumbersAndWords::TranslationsHelpers::Fr
|
6
|
-
|
7
|
-
private
|
8
|
-
|
9
|
-
def capacity_iteration capacity
|
10
|
-
words = []
|
11
|
-
capacity_words = words_in_capacity(capacity)
|
12
|
-
words.push(translation_megs(capacity)) unless capacity_words.empty?
|
13
|
-
words += capacity_words unless is_a_thousand?(capacity) and is_a_one?(capacity_words)
|
14
|
-
words
|
15
|
-
end
|
16
|
-
|
17
|
-
def is_a_one? capacity_words
|
18
|
-
[t(:ones)[1]] == capacity_words
|
19
|
-
end
|
20
|
-
|
21
|
-
def is_a_thousand? capacity
|
22
|
-
FiguresArray::THOUSAND_CAPACITY == capacity
|
23
|
-
end
|
24
|
-
|
25
|
-
def hundreds_number_to_words
|
26
|
-
simple_number_to_words + [
|
27
|
-
translation_hundreds(figures.hundreds, simple_number_to_words.empty?)
|
28
|
-
]
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module NumbersAndWords
|
2
|
-
module Strategies
|
3
|
-
class Nl < Base
|
4
|
-
include Families::Latin
|
5
|
-
include NumbersAndWords::TranslationsHelpers::Nl
|
6
|
-
|
7
|
-
def hundreds_number_to_words
|
8
|
-
[super.reverse.join]
|
9
|
-
end
|
10
|
-
|
11
|
-
def capacity_iteration capacity
|
12
|
-
if FiguresArray::THOUSAND_CAPACITY == capacity
|
13
|
-
words = []
|
14
|
-
capacity_words = words_in_capacity(capacity)
|
15
|
-
words.push(translation_megs(capacity)) unless capacity_words.empty?
|
16
|
-
capacity_words.empty? ? [] : [capacity_words, words].join
|
17
|
-
else
|
18
|
-
super
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'numbers_and_words/translations_helpers/base'
|
2
|
-
require 'numbers_and_words/translations_helpers/families/base'
|
3
|
-
require 'numbers_and_words/translations_helpers/families/cyrillic'
|
4
|
-
require 'numbers_and_words/translations_helpers/families/latin'
|
5
|
-
require 'numbers_and_words/translations_helpers/ru'
|
6
|
-
require 'numbers_and_words/translations_helpers/en'
|
7
|
-
require 'numbers_and_words/translations_helpers/ua'
|
8
|
-
require 'numbers_and_words/translations_helpers/tr'
|
9
|
-
require 'numbers_and_words/translations_helpers/fr'
|
10
|
-
require 'numbers_and_words/translations_helpers/nl'
|
11
|
-
require 'numbers_and_words/translations_helpers/it'
|
@@ -1,12 +0,0 @@
|
|
1
|
-
module NumbersAndWords
|
2
|
-
module TranslationsHelpers
|
3
|
-
module En
|
4
|
-
include NumbersAndWords::TranslationsHelpers::Base
|
5
|
-
include NumbersAndWords::TranslationsHelpers::Families::Latin
|
6
|
-
|
7
|
-
def translation_tens_with_ones numbers
|
8
|
-
super numbers, '-'
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module NumbersAndWords
|
2
|
-
module TranslationsHelpers
|
3
|
-
module Families
|
4
|
-
module Base
|
5
|
-
|
6
|
-
private
|
7
|
-
|
8
|
-
def translation_teens number
|
9
|
-
t(:teens)[number]
|
10
|
-
end
|
11
|
-
|
12
|
-
def translation_tens number
|
13
|
-
t(:tens)[number]
|
14
|
-
end
|
15
|
-
|
16
|
-
def translation_tens_with_ones numbers, separator = ' '
|
17
|
-
[translation_tens(numbers[1]), translation_ones(numbers[0])].join separator
|
18
|
-
end
|
19
|
-
|
20
|
-
def translation_megs capacity, number = nil
|
21
|
-
number ? t(translation_mega(capacity), :count => number) : t(:mega)[capacity]
|
22
|
-
end
|
23
|
-
|
24
|
-
def translation_mega capacity
|
25
|
-
t(:mega)[capacity]
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module NumbersAndWords
|
2
|
-
module TranslationsHelpers
|
3
|
-
module Families
|
4
|
-
module Cyrillic
|
5
|
-
include NumbersAndWords::TranslationsHelpers::Families::Base
|
6
|
-
|
7
|
-
private
|
8
|
-
|
9
|
-
def translation_ones number
|
10
|
-
gender = figures.is_a_thousand_capacity?(current_capacity) ? :female : :male
|
11
|
-
t([:ones, gender].join('_'))[number]
|
12
|
-
end
|
13
|
-
|
14
|
-
def translation_hundreds number
|
15
|
-
t(:hundreds)[number]
|
16
|
-
end
|
17
|
-
|
18
|
-
def translation_megs capacity
|
19
|
-
super(capacity, figures.number_in_capacity(capacity))
|
20
|
-
end
|
21
|
-
|
22
|
-
def zero
|
23
|
-
t(:ones_male)[0]
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module NumbersAndWords
|
2
|
-
module TranslationsHelpers
|
3
|
-
module Families
|
4
|
-
module Latin
|
5
|
-
include NumbersAndWords::TranslationsHelpers::Families::Base
|
6
|
-
|
7
|
-
private
|
8
|
-
|
9
|
-
def translation_ones number
|
10
|
-
t(:ones)[number]
|
11
|
-
end
|
12
|
-
|
13
|
-
def translation_hundreds number
|
14
|
-
[t(:ones)[number], t(:hundreds)].join ' '
|
15
|
-
end
|
16
|
-
|
17
|
-
def zero
|
18
|
-
t(:ones)[0]
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
module NumbersAndWords
|
2
|
-
module TranslationsHelpers
|
3
|
-
module Fr
|
4
|
-
include NumbersAndWords::TranslationsHelpers::Base
|
5
|
-
include NumbersAndWords::TranslationsHelpers::Families::Latin
|
6
|
-
|
7
|
-
SPECIAL_TENS_CASE = 8
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
def translation_tens number, alone = true
|
12
|
-
(SPECIAL_TENS_CASE == number and alone) ? t(:eighty) : super(number)
|
13
|
-
end
|
14
|
-
|
15
|
-
def translation_tens_with_ones numbers
|
16
|
-
if [7, 9].include? numbers[1]
|
17
|
-
[translation_tens(numbers[1] - 1, false), translation_teens(numbers[0])].join '-'
|
18
|
-
else
|
19
|
-
union = numbers[0] == 1 ? ' et ' : '-'
|
20
|
-
[translation_tens(numbers[1], false), translation_ones(numbers[0])].join union
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def translation_hundreds number, pluralize = false
|
25
|
-
hundreds = t(:hundreds, :count => pluralize ? number : 1)
|
26
|
-
(number == 1) ? hundreds : [t(:ones)[number], hundreds].join(' ')
|
27
|
-
end
|
28
|
-
|
29
|
-
def translation_megs capacity
|
30
|
-
super(capacity, figures.number_in_capacity(capacity))
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module NumbersAndWords
|
2
|
-
module TranslationsHelpers
|
3
|
-
module It
|
4
|
-
include NumbersAndWords::TranslationsHelpers::Base
|
5
|
-
include NumbersAndWords::TranslationsHelpers::Families::Latin
|
6
|
-
|
7
|
-
def translation_tens_with_ones numbers
|
8
|
-
super numbers, ''
|
9
|
-
end
|
10
|
-
|
11
|
-
def translation_hundreds number
|
12
|
-
[[number], t(:hundreds)].join ' '
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module NumbersAndWords
|
2
|
-
module TranslationsHelpers
|
3
|
-
module Nl
|
4
|
-
include NumbersAndWords::TranslationsHelpers::Base
|
5
|
-
include NumbersAndWords::TranslationsHelpers::Families::Latin
|
6
|
-
|
7
|
-
private
|
8
|
-
|
9
|
-
def translation_tens_with_ones numbers
|
10
|
-
[translation_ones(numbers[0]), translation_tens(numbers[1])].join 'en'
|
11
|
-
end
|
12
|
-
|
13
|
-
def translation_hundreds number
|
14
|
-
1 == number ? t(:hundreds) : [t(:ones)[number], t(:hundreds)].join
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|