kabal 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/kabal/languages/russian.rb +40 -26
- data/lib/kabal/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: d22c90bd40aac3a8ba178f098bba486a0bfc9d49
|
4
|
+
data.tar.gz: 2e3f54d404fd4585828a8587c381e8d1ea29c250
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ac8dce387eae4fee82ee671cb233cea6bee2b3043423fe12f1b66a6279bf27ddfe23e6d2089fc0a29ef6b2a26efb8c89745cef73476e931757eee5a24bd5428
|
7
|
+
data.tar.gz: 681ffb3be175372b594c56182b6cd3bcdcf2ab11babf0075c69fe1311f1e7c32f05cd4fbc8aa2688e328d82fc6700fdae19dbef0e7eeed73902d62be641b617c
|
data/README.md
CHANGED
@@ -13,11 +13,11 @@ class Kabal::Russian < Kabal::Language
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def single(number)
|
16
|
-
if
|
17
|
-
|
18
|
-
|
19
|
-
names[lang]["single"][number]
|
16
|
+
if @feminine_name_for_thousands
|
17
|
+
@feminine_name_for_thousands = false
|
18
|
+
return names[lang]["single_feminine"][count(number) % 10]
|
20
19
|
end
|
20
|
+
names[lang]["single"][number]
|
21
21
|
end
|
22
22
|
|
23
23
|
def two_words(number)
|
@@ -28,9 +28,7 @@ class Kabal::Russian < Kabal::Language
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def three_words(number)
|
31
|
-
if number / 100 == 0
|
32
|
-
return two_words number
|
33
|
-
end
|
31
|
+
return two_words number if number / 100 == 0
|
34
32
|
number_name = names[lang]["three_words"][number / 100]
|
35
33
|
return number_name += " " + two_words(number % 100) if (number % 100 >= 20)
|
36
34
|
return number_name += " " + single(number % 100) if (number % 100 != 0)
|
@@ -39,30 +37,46 @@ class Kabal::Russian < Kabal::Language
|
|
39
37
|
|
40
38
|
def ten_powers(number)
|
41
39
|
#FIXME find better way
|
42
|
-
|
43
|
-
if
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
40
|
+
return names[lang]["ten_powers"][100] if number_is_google? number
|
41
|
+
less_thousands number if number_is_thousands? number
|
42
|
+
return @number_name if number_is_thousands? number
|
43
|
+
create_number_name number
|
44
|
+
ten_powers(number % (10 ** number_order(number)))
|
45
|
+
end
|
46
|
+
|
47
|
+
def number_order(number)
|
48
|
+
((number.to_s.length - 1) / 3) * 3
|
49
|
+
end
|
50
|
+
|
51
|
+
def count(number)
|
52
|
+
number / (10 ** number_order(number))
|
53
|
+
end
|
54
|
+
|
55
|
+
def create_number_name(number)
|
53
56
|
if @number_name.nil?
|
54
|
-
@number_name = count_name + " " + Declinations.name_with_declination(names[lang]["ten_powers"][
|
55
|
-
elsif
|
56
|
-
@number_name += " " + count_name + " " + Declinations.name_with_declination(names[lang]["ten_powers"][
|
57
|
+
@number_name = count_name(number) + " " + Declinations.name_with_declination(names[lang]["ten_powers"][number_order(number)], count(number))
|
58
|
+
elsif count(number) != 0
|
59
|
+
@number_name += " " + count_name(number) + " " + Declinations.name_with_declination(names[lang]["ten_powers"][number_order(number)], count(number))
|
57
60
|
end
|
58
|
-
ten_powers(number % (10 ** @number_order))
|
59
61
|
end
|
60
62
|
|
61
|
-
def
|
62
|
-
|
63
|
+
def less_thousands(number)
|
64
|
+
unless number == 0
|
65
|
+
@number_name += " " + three_words(number % 1000)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def number_is_thousands?(number)
|
70
|
+
number_order(number) < 3
|
71
|
+
end
|
72
|
+
|
73
|
+
def count_name(number)
|
74
|
+
#FIXME number.to_S[-4] not good
|
75
|
+
@feminine_name_for_thousands = (number.to_s[-4] == "1" or number.to_s[-4] == "2") and count(number) and count(number) / 10 != 1 and number_order(number) == 3
|
76
|
+
three_words count(number)
|
63
77
|
end
|
64
78
|
|
65
|
-
def number_is_google?
|
66
|
-
|
79
|
+
def number_is_google?(number)
|
80
|
+
count(number) == 10 and number_order(number) == 99
|
67
81
|
end
|
68
82
|
end
|
data/lib/kabal/version.rb
CHANGED