to_russian_words 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/to_russian_words.rb +4 -4
- data/lib/to_russian_words/russian_gender_labels.rb +12 -0
- data/lib/to_russian_words/utils.rb +15 -12
- data/lib/to_russian_words/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76a4e11c1c88b6b6314f0aa1a3799fd43b505e7b
|
4
|
+
data.tar.gz: d4eaac1f43767afe425ec5eb99c570e32ce7d930
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b69998d59c7a3e8327eda7a716be631aba75ec7db9a73663fade52d9516225fbeffd74b65221a1eaddfcb6c17e83cccdf93f4323845aec88557e4db59f829db9
|
7
|
+
data.tar.gz: 7a0545fba7c84714b0602e9cbc0348f55430e0133b232e18ac7f8d6316526c2bc10c5854ff39a1893fcb5a40fff08b5acb4b8c8a1f56b0c24742e57fdb0d69c9
|
data/lib/to_russian_words.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module ToRussianWords
|
3
|
-
require
|
4
|
-
require_relative
|
5
|
-
require_relative
|
6
|
-
require_relative
|
3
|
+
require 'to_russian_words/version'
|
4
|
+
require_relative './to_russian_words/under_hundred.rb'
|
5
|
+
require_relative './to_russian_words/divisions.rb'
|
6
|
+
require_relative './to_russian_words/utils.rb'
|
7
7
|
|
8
8
|
include ToRussianWords::UnderHundred
|
9
9
|
include ToRussianWords::Divisions
|
@@ -1,24 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require_relative './under_hundred.rb'
|
3
3
|
require_relative "./divisions.rb"
|
4
|
+
require_relative "./russian_gender_labels.rb"
|
4
5
|
module ToRussianWords
|
5
6
|
module Utils
|
6
7
|
include UnderHundred
|
7
8
|
include Divisions
|
9
|
+
include RussianGenderLabels
|
8
10
|
|
9
11
|
def result_below_one_thousand(num, counter, russian_case)
|
10
12
|
hundred, remaining = num.divmod(100)
|
11
13
|
|
12
14
|
return higher_than_hundred(hundred, remaining, counter, russian_case) if hundred != 0
|
13
|
-
under_hundred(russian_case)[remaining] if hundred == 0 && remaining != 0
|
15
|
+
under_hundred(russian_case, counter == 1 ? num : nil)[remaining] if hundred == 0 && remaining != 0
|
14
16
|
end
|
15
17
|
|
16
18
|
def higher_than_hundred(hundred, remaining, counter, russian_case)
|
17
|
-
century = (hundred == 1 ? '' : under_hundred(russian_case)[hundred])
|
19
|
+
century = (hundred == 1 ? '' : under_hundred(russian_case, hundred)[hundred])
|
18
20
|
if remaining != 0
|
19
|
-
return century + "#{hundred_name(
|
21
|
+
return century + "#{hundred_name(hundred, russian_case)} " + under_hundred(russian_case)[remaining]
|
20
22
|
end
|
21
|
-
return century + "#{hundred_name(
|
23
|
+
return century + "#{hundred_name(hundred, russian_case)} " if remaining == 0
|
22
24
|
end
|
23
25
|
|
24
26
|
def check_sign(num)
|
@@ -31,12 +33,12 @@ module ToRussianWords
|
|
31
33
|
raise 'A whole number is expected'
|
32
34
|
end
|
33
35
|
|
34
|
-
def under_hundred(russian_case)
|
36
|
+
def under_hundred(russian_case, hundred = 0)
|
35
37
|
case russian_case
|
36
38
|
when 'dative'
|
37
|
-
DATIVE_UNDER_HUNDRED
|
39
|
+
[1, 2].include?(hundred) ? DATIVE_RUSSIAN_FEMALE_LABEL : DATIVE_UNDER_HUNDRED
|
38
40
|
else
|
39
|
-
NOMINATIVE_UNDER_HUNDRED
|
41
|
+
[1, 2].include?(hundred) ? NOMINATIVE_RUSSIAN_FEMALE_LABEL : NOMINATIVE_UNDER_HUNDRED
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
@@ -49,19 +51,20 @@ module ToRussianWords
|
|
49
51
|
end
|
50
52
|
end
|
51
53
|
|
52
|
-
def hundred_name(
|
53
|
-
remaining = remaining.to_s.last.to_i
|
54
|
+
def hundred_name(hundred, russian_case)
|
54
55
|
case russian_case
|
55
56
|
when 'dative'
|
56
|
-
if
|
57
|
+
if hundred == 1
|
57
58
|
'ста'
|
58
59
|
else
|
59
60
|
'сот'
|
60
61
|
end
|
61
62
|
else
|
62
|
-
if
|
63
|
+
if [1, 4].include? hundred
|
63
64
|
'сто'
|
64
|
-
elsif
|
65
|
+
elsif hundred == 2
|
66
|
+
'сти'
|
67
|
+
elsif hundred == 3
|
65
68
|
'ста'
|
66
69
|
else
|
67
70
|
'сот'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: to_russian_words
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vasiliy Gandzha
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- Rakefile
|
97
97
|
- lib/to_russian_words.rb
|
98
98
|
- lib/to_russian_words/divisions.rb
|
99
|
+
- lib/to_russian_words/russian_gender_labels.rb
|
99
100
|
- lib/to_russian_words/under_hundred.rb
|
100
101
|
- lib/to_russian_words/utils.rb
|
101
102
|
- lib/to_russian_words/version.rb
|