kabal 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/README.md +27 -4
- data/kabal.gemspec +1 -1
- data/lib/kabal/languages/russian/declinations.rb +21 -0
- data/lib/kabal/languages/russian.rb +3 -10
- data/lib/kabal/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: 8c20540f012d04c0f365c55626f1864c9c633c7a
|
4
|
+
data.tar.gz: de31917cc938b3e6c8bc8851639604a3ba77bf52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98038c6116b3d7c8a05b252220a4ccaef8c0cef0a874e849ee3be79688e5310fe146e132cd3bda0b89313680ccbadb49d2e7e01b8e837ebedd2dea08fc02b161
|
7
|
+
data.tar.gz: 9876b459c62d41804d39e9de8d07f53036bdff9bc62e511c00ad983728561b7906b33e37e4b37c99a1eb34e73da53659d1b5934649f8b3c4fc88955b3f26cecb
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -21,12 +21,35 @@ Or install it yourself as:
|
|
21
21
|
|
22
22
|
## Usage
|
23
23
|
|
24
|
-
|
24
|
+
Kabal has one main feature - number to text "converting".
|
25
|
+
|
26
|
+
require 'kabal'
|
27
|
+
Kabal.to_text 1 #=> "один"
|
28
|
+
|
29
|
+
You can choose language to "converting".
|
30
|
+
|
31
|
+
Kabal.language = "Russian"
|
32
|
+
|
33
|
+
Supported Languages:
|
34
|
+
|
35
|
+
* Russian
|
36
|
+
|
37
|
+
*More languages will be added later.*
|
25
38
|
|
26
39
|
## Contributing
|
27
40
|
|
28
|
-
1. Fork it ( https://github.com/
|
29
|
-
2. Create your feature branch (`git
|
30
|
-
3. Commit your changes (`git commit
|
41
|
+
1. Fork it ( https://github.com/kalashnikovisme/kabal/fork )
|
42
|
+
2. Create your feature branch (`git flow feature start new_super_feature`)
|
43
|
+
3. Commit your changes (`git commit`)
|
31
44
|
4. Push to the branch (`git push origin my-new-feature`)
|
32
45
|
5. Create a new Pull Request
|
46
|
+
|
47
|
+
## How add languages
|
48
|
+
|
49
|
+
To add Elfin language you should:
|
50
|
+
|
51
|
+
1. Create `lib/kabal/languages/elfin.rb`. You'll describe rules of this language to drawing numbers there.
|
52
|
+
2. Create `test/lib/kabal/languages/elfin_test.rb`. You'll cover your code by tests there.
|
53
|
+
3. Create `yaml/languages/el.yml`. You'll add numbers and words, which they correspond, there.
|
54
|
+
4. Add `Elfin: "el"` to `yaml/languages.yml`.
|
55
|
+
5. Add `require "kabal/languages/elfin"` to `lib/kabal/supported_languages.rb`.
|
data/kabal.gemspec
CHANGED
@@ -6,7 +6,7 @@ require 'kabal/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "kabal"
|
8
8
|
spec.version = Kabal::VERSION
|
9
|
-
spec.authors = ["
|
9
|
+
spec.authors = ["Pavel Kalashnikov"]
|
10
10
|
spec.email = ["kalashnikovisme@gmail.com"]
|
11
11
|
spec.summary = %q{Number To Text Helper}
|
12
12
|
spec.description = %q{Kabal allows you to translate numbers into text.}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Declinations
|
2
|
+
def self.name_with_declination(ten_power_name, count)
|
3
|
+
if ten_power_name[-1, 1] == "а"
|
4
|
+
return ten_power_name if ends_with_one? count
|
5
|
+
return ten_power_name[0..4] + "и" if end_with_two_or_three_of_four? count
|
6
|
+
ten_power_name[0..4]
|
7
|
+
else
|
8
|
+
return ten_power_name if ends_with_one? count
|
9
|
+
return ten_power_name + "а" if end_with_two_or_three_of_four? count
|
10
|
+
ten_power_name + "ов"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.ends_with_one?(count)
|
15
|
+
count.to_s[-1] == "1"
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.end_with_two_or_three_of_four?(count)
|
19
|
+
count.to_s[-1] == "2" or count.to_s[-1] == "3" or count.to_s[-1] == "4"
|
20
|
+
end
|
21
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'kabal/languages/language'
|
2
|
+
require 'kabal/languages/russian/declinations'
|
2
3
|
|
3
4
|
class Kabal::Russian < Kabal::Language
|
4
5
|
def convert(number)
|
@@ -50,9 +51,9 @@ class Kabal::Russian < Kabal::Language
|
|
50
51
|
return names[lang]["ten_powers"][100]
|
51
52
|
end
|
52
53
|
if @number_name.nil?
|
53
|
-
@number_name = count_name + " " + name_with_declination(names[lang]["ten_powers"][@number_order])
|
54
|
+
@number_name = count_name + " " + Declinations.name_with_declination(names[lang]["ten_powers"][@number_order], @count)
|
54
55
|
elsif @count != 0
|
55
|
-
@number_name += " " + count_name + " " + name_with_declination(names[lang]["ten_powers"][@number_order])
|
56
|
+
@number_name += " " + count_name + " " + Declinations.name_with_declination(names[lang]["ten_powers"][@number_order], @count)
|
56
57
|
end
|
57
58
|
ten_powers(number % (10 ** @number_order))
|
58
59
|
end
|
@@ -61,14 +62,6 @@ class Kabal::Russian < Kabal::Language
|
|
61
62
|
three_words @count
|
62
63
|
end
|
63
64
|
|
64
|
-
def name_with_declination(ten_power_name)
|
65
|
-
if ten_power_name[-1, 1] == "а"
|
66
|
-
Russian.p(@count, ten_power_name, ten_power_name[0..4] + "и", ten_power_name[0..4])
|
67
|
-
else
|
68
|
-
Russian.p(@count, ten_power_name, ten_power_name + "а", ten_power_name + "ов")
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
65
|
def number_is_google?
|
73
66
|
@count == 10 and @number_order == 99
|
74
67
|
end
|
data/lib/kabal/version.rb
CHANGED
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kabal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Pavel Kalashnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- lib/kabal/errors/number_out_range_error.rb
|
60
60
|
- lib/kabal/languages/language.rb
|
61
61
|
- lib/kabal/languages/russian.rb
|
62
|
+
- lib/kabal/languages/russian/declinations.rb
|
62
63
|
- lib/kabal/supported_languages.rb
|
63
64
|
- lib/kabal/version.rb
|
64
65
|
- test/lib/kabal/languages/russian_test.rb
|