to_russian_words 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/lib/to_russian_words.rb +1 -1
- data/lib/to_russian_words/divisions.rb +14 -14
- data/lib/to_russian_words/utils.rb +17 -6
- data/lib/to_russian_words/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 346812726e96d15239f6716e319645cf612fd2c2
|
4
|
+
data.tar.gz: 2c260974caa40d84de6bf2ad29b1e7ccb8567266
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 318b675911dcd1312837617dd05de09a45c758e9ff613fb24d691dc90238ed2b670270527dfa9e13bb9b443cf767e79acfbcacb67abb82bff68da70a2c3a3f8a
|
7
|
+
data.tar.gz: dde4be3a41c0a2365e98eaa176bedbadca3fdc46cb16722bf02aa3276d118b56a0d3dd797fa71e14c82df0c3303420bfb63b6cbde7fafa3e0f5950a8ad9b46e6
|
data/README.md
CHANGED
@@ -7,16 +7,18 @@ e.g.
|
|
7
7
|
25.to_words('dative') # "двадцати пяти"
|
8
8
|
70.to_words('dative') # "семидесяти"
|
9
9
|
70.to_words() # "семьдесят"
|
10
|
+
|
11
|
+
With large numbers may be inaccurate, fix ... soon :)
|
10
12
|
|
11
13
|
## Installation
|
12
14
|
|
13
15
|
Add this line to your application's Gemfile:
|
14
16
|
|
15
|
-
gem 'to_words',
|
17
|
+
gem 'to_words', '1.1.1'
|
16
18
|
|
17
19
|
And then execute:
|
18
20
|
|
19
|
-
$ bundle
|
21
|
+
$ bundle install
|
20
22
|
|
21
23
|
## Usage
|
22
24
|
|
data/lib/to_russian_words.rb
CHANGED
@@ -22,7 +22,7 @@ module ToRussianWords
|
|
22
22
|
while num != 0
|
23
23
|
num, remaining = num.divmod(1000)
|
24
24
|
temp_result = result_below_one_thousand(remaining, counter, russian_case)
|
25
|
-
result << temp_result + ' ' + divisions(russian_case)[counter]
|
25
|
+
result << temp_result + ' ' + divisions(russian_case)[counter][remaining.to_s.last.to_i] if temp_result
|
26
26
|
counter += 1
|
27
27
|
end
|
28
28
|
sign + result.reverse.join(' ').rstrip
|
@@ -2,23 +2,23 @@
|
|
2
2
|
module ToRussianWords
|
3
3
|
module Divisions
|
4
4
|
NOMINATIVE_DIVISIONS = [
|
5
|
-
'',
|
6
|
-
'тысяч',
|
7
|
-
'миллион',
|
8
|
-
'миллиард',
|
9
|
-
'триллион',
|
10
|
-
'квадрильон',
|
11
|
-
'нониллион'
|
5
|
+
([''] * 10),
|
6
|
+
['', 'тысяча', (['тысячи'] * 3), (['тысяч'] * 5)].flatten,
|
7
|
+
['', 'миллион', (['миллиона'] * 3), (['миллионов'] * 5)].flatten,
|
8
|
+
['', 'миллиард', (['миллиарда'] * 3), (['миллиардов'] * 5)].flatten,
|
9
|
+
['', 'триллион', (['триллиона'] * 3), (['триллионов'] * 5)].flatten,
|
10
|
+
['', 'квадрильон', (['квадрильона'] * 3), (['квадрильонов'] * 5)].flatten,
|
11
|
+
['', 'нониллион', (['нониллиона'] * 3), (['нониллионов'] * 5)].flatten
|
12
12
|
].freeze
|
13
13
|
|
14
14
|
DATIVE_DIVISIONS = [
|
15
|
-
'',
|
16
|
-
'тысячи',
|
17
|
-
'миллиона',
|
18
|
-
'миллиарда',
|
19
|
-
'триллиона',
|
20
|
-
'квадрильона',
|
21
|
-
'нониллиона'
|
15
|
+
([''] * 10),
|
16
|
+
['', 'тысячи', (['тысяч'] * 8)].flatten,
|
17
|
+
['', 'миллиона', (['миллионов'] * 8)].flatten,
|
18
|
+
['', 'миллиарда', (['миллиардов'] * 8)].flatten,
|
19
|
+
['', 'триллиона', (['триллионов'] * 8)].flatten,
|
20
|
+
['', 'квадрильона', (['квадрильонов'] * 8)].flatten,
|
21
|
+
['', 'нониллиона', (['нониллионов'] * 8)].flatten,
|
22
22
|
].freeze
|
23
23
|
end
|
24
24
|
end
|
@@ -14,11 +14,11 @@ module ToRussianWords
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def higher_than_hundred(hundred, remaining, counter, russian_case)
|
17
|
-
century = under_hundred(russian_case)[hundred]
|
17
|
+
century = (hundred == 1 ? '' : under_hundred(russian_case)[hundred])
|
18
18
|
if remaining != 0
|
19
|
-
return century + "#{hundred_name(russian_case)} " + under_hundred(russian_case)[remaining]
|
19
|
+
return century + "#{hundred_name(russian_case, remaining)} " + under_hundred(russian_case)[remaining]
|
20
20
|
end
|
21
|
-
return century + "#{hundred_name(russian_case)} " if remaining == 0
|
21
|
+
return century + "#{hundred_name(russian_case, remaining)} " if remaining == 0
|
22
22
|
end
|
23
23
|
|
24
24
|
def check_sign(num)
|
@@ -49,12 +49,23 @@ module ToRussianWords
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
def hundred_name(russian_case)
|
52
|
+
def hundred_name(russian_case, remaining)
|
53
|
+
remaining = remaining.to_s.last.to_i
|
53
54
|
case russian_case
|
54
55
|
when 'dative'
|
55
|
-
|
56
|
+
if remaining == 1
|
57
|
+
'ста'
|
58
|
+
else
|
59
|
+
'сот'
|
60
|
+
end
|
56
61
|
else
|
57
|
-
|
62
|
+
if remaining == 1
|
63
|
+
'сто'
|
64
|
+
elsif remaining.between?(2, 4)
|
65
|
+
'ста'
|
66
|
+
else
|
67
|
+
'сот'
|
68
|
+
end
|
58
69
|
end
|
59
70
|
end
|
60
71
|
end
|