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.
Files changed (116) hide show
  1. checksums.yaml +15 -0
  2. data/README.rdoc +90 -1
  3. data/lib/numbers_and_words.rb +4 -3
  4. data/lib/numbers_and_words/core_ext.rb +1 -0
  5. data/lib/numbers_and_words/core_ext/array.rb +1 -1
  6. data/lib/numbers_and_words/core_ext/float.rb +5 -0
  7. data/lib/numbers_and_words/core_ext/integer.rb +2 -9
  8. data/lib/numbers_and_words/helper_classes.rb +2 -0
  9. data/lib/numbers_and_words/helper_classes/array_extensions/helpers.rb +81 -0
  10. data/lib/numbers_and_words/helper_classes/array_extensions/validations.rb +19 -0
  11. data/lib/numbers_and_words/helper_classes/figures_array.rb +18 -0
  12. data/lib/numbers_and_words/helper_classes/words_array.rb +11 -0
  13. data/lib/numbers_and_words/i18n/locales/numbers.en.yml +48 -0
  14. data/lib/numbers_and_words/i18n/locales/numbers.es.yml +15 -0
  15. data/lib/numbers_and_words/i18n/locales/numbers.hu.yml +16 -0
  16. data/lib/numbers_and_words/i18n/locales/numbers.ru.yml +27 -3
  17. data/lib/numbers_and_words/i18n/locales/numbers.se.yml +7 -0
  18. data/lib/numbers_and_words/i18n/locales/numbers.ua.yml +14 -2
  19. data/lib/numbers_and_words/i18n/pluralization.rb +1 -0
  20. data/lib/numbers_and_words/i18n/plurals/es.rb +11 -0
  21. data/lib/numbers_and_words/strategies.rb +16 -11
  22. data/lib/numbers_and_words/strategies/array_joiner.rb +31 -0
  23. data/lib/numbers_and_words/strategies/figures_converter.rb +33 -0
  24. data/lib/numbers_and_words/strategies/figures_converter/decorators.rb +39 -0
  25. data/lib/numbers_and_words/strategies/figures_converter/decorators/base.rb +18 -0
  26. data/lib/numbers_and_words/strategies/figures_converter/decorators/en.rb +3 -0
  27. data/lib/numbers_and_words/strategies/figures_converter/decorators/en/base.rb +12 -0
  28. data/lib/numbers_and_words/strategies/figures_converter/decorators/en/fractional.rb +38 -0
  29. data/lib/numbers_and_words/strategies/figures_converter/decorators/en/integral.rb +12 -0
  30. data/lib/numbers_and_words/strategies/figures_converter/decorators/hu.rb +3 -0
  31. data/lib/numbers_and_words/strategies/figures_converter/decorators/hu/base.rb +12 -0
  32. data/lib/numbers_and_words/strategies/figures_converter/decorators/hu/fractional.rb +38 -0
  33. data/lib/numbers_and_words/strategies/figures_converter/decorators/hu/integral.rb +12 -0
  34. data/lib/numbers_and_words/strategies/figures_converter/decorators/ru.rb +3 -0
  35. data/lib/numbers_and_words/strategies/figures_converter/decorators/ru/base.rb +12 -0
  36. data/lib/numbers_and_words/strategies/figures_converter/decorators/ru/fractional.rb +39 -0
  37. data/lib/numbers_and_words/strategies/figures_converter/decorators/ru/integral.rb +27 -0
  38. data/lib/numbers_and_words/strategies/figures_converter/decorators/ua.rb +3 -0
  39. data/lib/numbers_and_words/strategies/figures_converter/decorators/ua/base.rb +12 -0
  40. data/lib/numbers_and_words/strategies/figures_converter/decorators/ua/fractional.rb +39 -0
  41. data/lib/numbers_and_words/strategies/figures_converter/decorators/ua/integral.rb +27 -0
  42. data/lib/numbers_and_words/strategies/figures_converter/languages.rb +39 -0
  43. data/lib/numbers_and_words/strategies/figures_converter/languages/base.rb +29 -0
  44. data/lib/numbers_and_words/strategies/figures_converter/languages/en.rb +48 -0
  45. data/lib/numbers_and_words/strategies/figures_converter/languages/es.rb +37 -0
  46. data/lib/numbers_and_words/strategies/figures_converter/languages/families/base.rb +77 -0
  47. data/lib/numbers_and_words/strategies/figures_converter/languages/families/cyrillic.rb +34 -0
  48. data/lib/numbers_and_words/strategies/figures_converter/languages/families/helpers.rb +36 -0
  49. data/lib/numbers_and_words/strategies/figures_converter/languages/families/latin.rb +13 -0
  50. data/lib/numbers_and_words/strategies/figures_converter/languages/fr.rb +37 -0
  51. data/lib/numbers_and_words/strategies/figures_converter/languages/hu.rb +63 -0
  52. data/lib/numbers_and_words/strategies/figures_converter/languages/it.rb +11 -0
  53. data/lib/numbers_and_words/strategies/figures_converter/languages/nl.rb +26 -0
  54. data/lib/numbers_and_words/strategies/figures_converter/languages/ru.rb +11 -0
  55. data/lib/numbers_and_words/strategies/figures_converter/languages/se.rb +11 -0
  56. data/lib/numbers_and_words/strategies/figures_converter/languages/tr.rb +11 -0
  57. data/lib/numbers_and_words/strategies/figures_converter/languages/ua.rb +11 -0
  58. data/lib/numbers_and_words/strategies/figures_converter/options.rb +41 -0
  59. data/lib/numbers_and_words/strategies/figures_converter/options/en.rb +4 -0
  60. data/lib/numbers_and_words/strategies/figures_converter/options/en/hundreds_with_union.rb +33 -0
  61. data/lib/numbers_and_words/strategies/figures_converter/options/en/ordinal.rb +60 -0
  62. data/lib/numbers_and_words/strategies/figures_converter/options/en/remove_hyphen.rb +29 -0
  63. data/lib/numbers_and_words/strategies/figures_converter/options/en/remove_zero.rb +29 -0
  64. data/lib/numbers_and_words/strategies/figures_converter/options/hu.rb +1 -0
  65. data/lib/numbers_and_words/strategies/figures_converter/options/hu/ordinal.rb +60 -0
  66. data/lib/numbers_and_words/strategies/figures_converter/options/ru.rb +1 -0
  67. data/lib/numbers_and_words/strategies/figures_converter/options/ru/gender.rb +28 -0
  68. data/lib/numbers_and_words/strategies/figures_converter/options/ua.rb +1 -0
  69. data/lib/numbers_and_words/strategies/figures_converter/options/ua/gender.rb +28 -0
  70. data/lib/numbers_and_words/translations.rb +25 -0
  71. data/lib/numbers_and_words/{translations_helpers → translations}/base.rb +2 -2
  72. data/lib/numbers_and_words/translations/en.rb +8 -0
  73. data/lib/numbers_and_words/translations/es.rb +37 -0
  74. data/lib/numbers_and_words/translations/extensions/fraction_significance.rb +25 -0
  75. data/lib/numbers_and_words/translations/families/base.rb +33 -0
  76. data/lib/numbers_and_words/translations/families/cyrillic.rb +29 -0
  77. data/lib/numbers_and_words/translations/families/latin.rb +23 -0
  78. data/lib/numbers_and_words/translations/fr.rb +29 -0
  79. data/lib/numbers_and_words/translations/hu.rb +26 -0
  80. data/lib/numbers_and_words/translations/it.rb +15 -0
  81. data/lib/numbers_and_words/translations/nl.rb +15 -0
  82. data/lib/numbers_and_words/translations/ru.rb +25 -0
  83. data/lib/numbers_and_words/translations/se.rb +11 -0
  84. data/lib/numbers_and_words/translations/tr.rb +11 -0
  85. data/lib/numbers_and_words/translations/ua.rb +21 -0
  86. data/lib/numbers_and_words/version.rb +1 -1
  87. data/lib/numbers_and_words/wrappers.rb +2 -0
  88. data/lib/numbers_and_words/wrappers/float.rb +60 -0
  89. data/lib/numbers_and_words/wrappers/integer.rb +21 -0
  90. metadata +81 -44
  91. data/lib/numbers_and_words/array_additions.rb +0 -2
  92. data/lib/numbers_and_words/array_additions/helpers.rb +0 -44
  93. data/lib/numbers_and_words/array_additions/validations.rb +0 -9
  94. data/lib/numbers_and_words/figures_array.rb +0 -15
  95. data/lib/numbers_and_words/strategies/base.rb +0 -18
  96. data/lib/numbers_and_words/strategies/en.rb +0 -8
  97. data/lib/numbers_and_words/strategies/families/base.rb +0 -71
  98. data/lib/numbers_and_words/strategies/families/cyrillic.rb +0 -18
  99. data/lib/numbers_and_words/strategies/families/latin.rb +0 -9
  100. data/lib/numbers_and_words/strategies/fr.rb +0 -32
  101. data/lib/numbers_and_words/strategies/it.rb +0 -8
  102. data/lib/numbers_and_words/strategies/nl.rb +0 -23
  103. data/lib/numbers_and_words/strategies/ru.rb +0 -8
  104. data/lib/numbers_and_words/strategies/tr.rb +0 -8
  105. data/lib/numbers_and_words/strategies/ua.rb +0 -8
  106. data/lib/numbers_and_words/translations_helpers.rb +0 -11
  107. data/lib/numbers_and_words/translations_helpers/en.rb +0 -12
  108. data/lib/numbers_and_words/translations_helpers/families/base.rb +0 -30
  109. data/lib/numbers_and_words/translations_helpers/families/cyrillic.rb +0 -28
  110. data/lib/numbers_and_words/translations_helpers/families/latin.rb +0 -23
  111. data/lib/numbers_and_words/translations_helpers/fr.rb +0 -34
  112. data/lib/numbers_and_words/translations_helpers/it.rb +0 -16
  113. data/lib/numbers_and_words/translations_helpers/nl.rb +0 -18
  114. data/lib/numbers_and_words/translations_helpers/ru.rb +0 -8
  115. data/lib/numbers_and_words/translations_helpers/tr.rb +0 -8
  116. data/lib/numbers_and_words/translations_helpers/ua.rb +0 -8
@@ -0,0 +1,15 @@
1
+ es:
2
+ numbers:
3
+ ones: [cero, uno, dos, tres, cuatro, cinco, seis, siete, ocho, nueve]
4
+ one: un
5
+
6
+ teens: [diez, once, doce, trece, catorce, quince, dieciseis, diecisiete, dieciocho, diecinueve]
7
+ tens: [cero, diez, veinti, treinta, cuarenta, cincuenta, sesenta, setenta, ochenta, noventa]
8
+ twenty: veinte
9
+
10
+ hundreds: [ciento, doscientos, trescientos, cuatrocientos, quinientos, seiscientos, setecientos, ochocientos, novecientos]
11
+ one_hundred: cien
12
+
13
+ mega: [ones, mil, millón, millardo, billón, billardo, trillón, trillardo, quadrillón, quadrillardo, quintillón, quintillardo]
14
+ megas: [ones, mil, millones, millardos, billones, billardos, trillones, trillardos, quadrillones, quadrillardos, quintillones, quintillardos]
15
+
@@ -0,0 +1,16 @@
1
+ hu:
2
+ numbers:
3
+ ones: [nulla, egy, kettő, három, négy, öt, hat, hét, nyolc, kilenc]
4
+ ones_with_tens: [nulla, egy, kettő, három, négy, öt, hat, hét, nyolc, kilenc]
5
+ tens: [nulla, tíz, húsz, harminc, negyven, ötven, hatvan, hetven, nyolcvan, kilencven]
6
+ tens_with_ones: [nulla, tizen, huszon, harminc, negyven, ötven, hatvan, hetven, nyolcvan, kilencven]
7
+ hundreds: száz
8
+ mega: [egy, ezer, millió, milliárd, billió, billiárd, trillió, trilliárd, kvadrillió, kvadrilliárd, kvintillió, kvintilliárd]
9
+ union: egész
10
+ ordinal:
11
+ ones: [nulladik, első, második, harmadik, negyedik, ötödik, hatodik, hetedik, nyolcadik, kilencedik]
12
+ ones_with_tens: [nulladik, egyedik, kettedik, harmadik, negyedik, ötödik, hatodik, hetedik, nyolcadik, kilencedik]
13
+ tens: [nulladik, tizedik, huszadik, harmincadik, negyvenedik, ötvenedik, hatvanadik, hetvenedik, nyolcvanadik, kilencvenedik]
14
+ hundreds: századik
15
+ mega: [nulladik, ezredik, milliomodik, milliárdodik, billiomodik, billiárdodik, trilliomodik, trilliárdodik, kvadrilliomodik, kvadrilliárdodik, kvintilliomodik, kvintilliárdodik]
16
+ micro: [_, tized, század, ezred, milliomod, milliárdod, billiomod, billiárdod, trilliomod, trilliárdod, kvadrilliomod, kvadrilliárdod, kvintilliomod, kvintilliárdod]
@@ -1,10 +1,22 @@
1
1
  ru:
2
2
  numbers:
3
- ones_male: [ноль, один, два, три, четыре, пять, шесть, семь, восемь, девять]
4
- ones_female: [ноль, однa, двe, три, четыре, пять, шесть, семь, восемь, девять]
3
+ ones:
4
+ male: [ноль, один, два, три, четыре, пять, шесть, семь, восемь, девять]
5
+ female: [ноль, одна, двe, три, четыре, пять, шесть, семь, восемь, девять]
6
+ neuter: [ноль, одно, два, три, четыре, пять, шесть, семь, восемь, девять]
5
7
  teens: [десять, одиннадцать, двенадцать, тринадцать, четырнадцать, пятнадцать, шестнадцать, семнадцать, восемнадцать, девятнадцать]
6
8
  tens: [ноль, десять, двадцать, тридцать, сорок, пятьдесят, шестьдесят, семьдесят, восемьдесят, девяносто]
7
9
  hundreds: [ноль, сто, двести, триста, четыреста, пятьсот, шестьсот, семьсот, восемьсот, девятьсот]
10
+ union: 'и'
11
+ micro:
12
+ one: [_, десятая, сотая, тысячная, миллионная, миллиардная, триллионная]
13
+ few: [_, десятых, сотых, тысячных, миллионных, миллиардных, триллионных]
14
+ many: [_, десятых, сотых, тысячных, миллионных, миллиардных, триллионных]
15
+ sub_micro: [_, десяти, сто]
16
+ integral:
17
+ one: целая
18
+ few: целых
19
+ many: целых
8
20
  thousands:
9
21
  one: тысяча
10
22
  few: тысячи
@@ -49,4 +61,16 @@ ru:
49
61
  one: дециллион
50
62
  few: дециллиона
51
63
  many: дециллионов
52
- mega: [ones, thousands, millions, billions, trillions, quadrillions, quintillion, sextillions, septillions, octillions, nonillions, decillions]
64
+ mega:
65
+ - ones
66
+ - thousands
67
+ - millions
68
+ - billions
69
+ - trillions
70
+ - quadrillions
71
+ - quintillion
72
+ - sextillions
73
+ - septillions
74
+ - octillions
75
+ - nonillions
76
+ - decillions
@@ -0,0 +1,7 @@
1
+ se:
2
+ numbers:
3
+ ones: [noll, en, två, tre, fyra, fem, sex, sju, åtta, nio]
4
+ teens: [tio, elva, tolv, tretton, fjorton, femton, sexton, sjutton, arton, nitton]
5
+ tens: [noll, tio, tjugo, trettio, fyrtio, femtio, sextio, sjuttio, åttio, nittio]
6
+ hundreds: hundra
7
+ mega: [ett, tusen, miljoner, miljarder, biljoner, kvadriljon, kvintiljon, sextillion, septillion, octillion, nonillion, decillion]
@@ -1,10 +1,22 @@
1
1
  ua:
2
2
  numbers:
3
- ones_male: [нуль, один, два, три, чотири, п’ять, шiсть, сiм, вiсiм, дев’ять]
4
- ones_female: [нуль, однa, двi, три, чотири, п’ять, шiсть, сiм, вiсiм, дев’ять]
3
+ ones:
4
+ male: [нуль, один, два, три, чотири, п’ять, шiсть, сiм, вiсiм, дев’ять]
5
+ female: [нуль, одна, двi, три, чотири, п’ять, шiсть, сiм, вiсiм, дев’ять]
6
+ neuter: [нуль, одне, два, три, чотири, п’ять, шiсть, сiм, вiсiм, дев’ять]
5
7
  teens: [десять, одинадцять, дванадцять, тринадцять, чотирнадцять, п’ятнадцять, шiстнадцять, сiмнадцять, вiсiмнадцять, дев’ятнадцять]
6
8
  tens: [нуль, десять, двадцять, тридцять, сорок, п’ятдесят, шiстдесят, сiмдесят, вiсiмдесят, дев’яносто]
7
9
  hundreds: [нуль, сто, двiстi, триста, чотириста, п’ятсот, шiстсот, сiмсот, вiсiмсот, дев’ятсот]
10
+ union: 'i'
11
+ micro:
12
+ one: [_, десята, сота, тысячна, мiльйонна, мiльярдна, трильйонна]
13
+ few: [_, десятих, сотих, тисячних, мiльйонних, мiльярдних, трильйонних]
14
+ many: [_, десятих, сотих, тисячних, мiльйонних, мiльярдних, трильйонних]
15
+ sub_micro: [_, десяти, сто]
16
+ integral:
17
+ one: цiла
18
+ few: цiлих
19
+ many: цiлих
8
20
  thousands:
9
21
  one: тисяча
10
22
  few: тисячi
@@ -1,6 +1,7 @@
1
1
  require 'numbers_and_words/i18n/plurals/ru'
2
2
  require 'numbers_and_words/i18n/plurals/ua'
3
3
  require 'numbers_and_words/i18n/plurals/fr'
4
+ require 'numbers_and_words/i18n/plurals/es'
4
5
 
5
6
  module NumbersAndWords
6
7
  module I18n
@@ -0,0 +1,11 @@
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
@@ -1,11 +1,16 @@
1
- require 'numbers_and_words/strategies/base'
2
- require 'numbers_and_words/strategies/families/base'
3
- require 'numbers_and_words/strategies/families/cyrillic'
4
- require 'numbers_and_words/strategies/families/latin'
5
- require 'numbers_and_words/strategies/ru'
6
- require 'numbers_and_words/strategies/en'
7
- require 'numbers_and_words/strategies/ua'
8
- require 'numbers_and_words/strategies/tr'
9
- require 'numbers_and_words/strategies/fr'
10
- require 'numbers_and_words/strategies/nl'
11
- require 'numbers_and_words/strategies/it'
1
+ require 'numbers_and_words/strategies/figures_converter'
2
+ require 'numbers_and_words/strategies/array_joiner'
3
+
4
+ module NumbersAndWords
5
+ module Strategies
6
+ class << self
7
+ def figures_converter
8
+ FiguresConverter::Base
9
+ end
10
+
11
+ def array_joiner
12
+ ArrayJoiner::Base
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,31 @@
1
+ module NumbersAndWords
2
+ module Strategies
3
+ module ArrayJoiner
4
+ class Base
5
+
6
+ attr_accessor :options, :elements
7
+
8
+ def initialize elements, options = {}
9
+ @elements = elements
10
+ @options = options
11
+ @translations = Translations.factory
12
+ end
13
+
14
+ def run
15
+ around { elements.join union_separator }
16
+ end
17
+
18
+ private
19
+
20
+ def union_separator
21
+ separator = options[:union_separator] || @translations.union || ''
22
+ " #{separator} " if separator.present?
23
+ end
24
+
25
+ def around
26
+ yield
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,33 @@
1
+ require 'numbers_and_words/strategies/figures_converter/languages'
2
+ require 'numbers_and_words/strategies/figures_converter/options'
3
+ require 'numbers_and_words/strategies/figures_converter/decorators'
4
+
5
+ module NumbersAndWords
6
+ module Strategies
7
+ module FiguresConverter
8
+ class Base
9
+
10
+ attr_accessor :options, :figures, :translations, :language, :decorator
11
+
12
+ def initialize figures, options = {}
13
+ @figures = figures.reverse
14
+
15
+ @decorator = Decorators.factory(self, options)
16
+ @options = Options::Proxy.new(self, options)
17
+ @translations = Translations.factory
18
+ @language = Languages.factory(self)
19
+ end
20
+
21
+ def run
22
+ around { language.words }
23
+ end
24
+
25
+ private
26
+
27
+ def around
28
+ decorator.run { yield }
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,39 @@
1
+ require 'numbers_and_words/strategies/figures_converter/decorators/base'
2
+ require 'numbers_and_words/strategies/figures_converter/decorators/en'
3
+ require 'numbers_and_words/strategies/figures_converter/decorators/ru'
4
+ require 'numbers_and_words/strategies/figures_converter/decorators/hu'
5
+ require 'numbers_and_words/strategies/figures_converter/decorators/ua'
6
+
7
+ module NumbersAndWords
8
+ module Strategies
9
+ module FiguresConverter
10
+ module Decorators
11
+ class << self
12
+ AVAILABLE = [:integral, :fractional]
13
+
14
+ def factory strategy, options
15
+ enabled_decorator(options).new strategy, options
16
+ end
17
+
18
+ private
19
+
20
+ def enabled_decorator options
21
+ decorator_class AVAILABLE.select { |name| !options[name].nil? }.first
22
+ end
23
+
24
+ def decorator_class method_name
25
+ method_name ? decorator_class_name(method_name).constantize : Decorators::Base
26
+ end
27
+
28
+ def decorator_class_name method_name
29
+ "#{name}::#{language_class_name}::#{method_name.to_s.camelcase}"
30
+ end
31
+
32
+ def language_class_name
33
+ ::I18n.locale.to_s.titleize.gsub ' ', '::'
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,18 @@
1
+ module NumbersAndWords
2
+ module Strategies
3
+ module FiguresConverter
4
+ module Decorators
5
+ class Base
6
+ def initialize strategy, options
7
+ @strategy = strategy
8
+ @options = options
9
+ end
10
+
11
+ def run
12
+ yield
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ require 'numbers_and_words/strategies/figures_converter/decorators/en/base'
2
+ require 'numbers_and_words/strategies/figures_converter/decorators/en/fractional'
3
+ require 'numbers_and_words/strategies/figures_converter/decorators/en/integral'
@@ -0,0 +1,12 @@
1
+ module NumbersAndWords
2
+ module Strategies
3
+ module FiguresConverter
4
+ module Decorators
5
+ module En
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 En
6
+ class Fractional < Base
7
+
8
+ def run
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,12 @@
1
+ module NumbersAndWords
2
+ module Strategies
3
+ module FiguresConverter
4
+ module Decorators
5
+ module En
6
+ class Integral < Base
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ require 'numbers_and_words/strategies/figures_converter/decorators/hu/base'
2
+ require 'numbers_and_words/strategies/figures_converter/decorators/hu/fractional'
3
+ require 'numbers_and_words/strategies/figures_converter/decorators/hu/integral'
@@ -0,0 +1,12 @@
1
+ module NumbersAndWords
2
+ module Strategies
3
+ module FiguresConverter
4
+ module Decorators
5
+ module Hu
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 Hu
6
+ class Fractional < Base
7
+
8
+ def run
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,12 @@
1
+ module NumbersAndWords
2
+ module Strategies
3
+ module FiguresConverter
4
+ module Decorators
5
+ module Hu
6
+ class Integral < Base
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ require 'numbers_and_words/strategies/figures_converter/decorators/ru/base'
2
+ require 'numbers_and_words/strategies/figures_converter/decorators/ru/fractional'
3
+ require 'numbers_and_words/strategies/figures_converter/decorators/ru/integral'
@@ -0,0 +1,12 @@
1
+ module NumbersAndWords
2
+ module Strategies
3
+ module FiguresConverter
4
+ module Decorators
5
+ module Ru
6
+ class Base < Decorators::Base
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end