kabal 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc725820d84c44702241e372e5ed2b85cb38bc3a
4
- data.tar.gz: ec3329559be4a8c3a65b938014faa401c82c9496
3
+ metadata.gz: 08e4ee26ce056a29fc5170e2dae9aafb09646e48
4
+ data.tar.gz: ebe8eb272d894fcb5978f810aa10147afe64a59a
5
5
  SHA512:
6
- metadata.gz: 6860d8a77351e36d445ab966848126e9c4081403e4ae6919f7382c2e26c2bb16649de055c45b912fdf0d7e87be5abdae597ee18fe58af79ccbc9c4968902338f
7
- data.tar.gz: 53eb4b57612e2e12841072f7bc25e58fd7bf6fff66c4a93173e32f6ba800c7b80473f1f771eb5609a12e047fca9250450077a712f48411e1e55d2e28c5e49741
6
+ metadata.gz: 39857db4c41b30a3fd95bc2acbe343ec1f3dc439f1f4ca1ee01562ab999d94e69e9bd7dddc68a9e031051711c9ebbc1412cb4765fb15db48f7940bf48c8ce101
7
+ data.tar.gz: 8e8b0398be6979358f4192fcd47e968dba963b5325e06bb0a87b4800515c7451358e6c5d3e4476a66ba8d2a3119a7a5030d4ab3a5e0e4e3dd227e2a8a42b048c
@@ -6,13 +6,13 @@ module Kabal
6
6
  end
7
7
 
8
8
  def whole_part_name(number)
9
- count = number.to_s.split('.')[0].to_i
9
+ count = number.floor
10
10
  natural_number_name(count)
11
11
  end
12
12
 
13
13
  def fractional_part_name(number)
14
14
  name = ""
15
- count_string = number.to_s.split('.')[1]
15
+ count_string = fractional_part_string(number).split('.')[1]
16
16
  count = count_string.to_i
17
17
  if count_string.size != count.to_s.size
18
18
  (count_string.size - count.to_s.size).times do
@@ -23,6 +23,20 @@ module Kabal
23
23
  natural_number_name(count)
24
24
  end
25
25
  end
26
+
27
+ def fractional_part_string(number)
28
+ "%.#{fractional_part_order(number)}f" % number
29
+ end
30
+
31
+ def fractional_part_order(number)
32
+ #FIXME find better way with whole 0 numbers
33
+ number_string = number.to_s
34
+ if number_string.include? "-"
35
+ number_string.split('-')[1].to_i
36
+ else
37
+ number_string.split('.')[1].length
38
+ end
39
+ end
26
40
  end
27
41
  end
28
42
  end
@@ -10,13 +10,13 @@ module Kabal
10
10
  end
11
11
 
12
12
  def whole_part_name(number)
13
- count = number.to_s.split('.')[0].to_i
13
+ count = number.floor
14
14
  count != 0 ? natural_number_name(count) : ""
15
15
  end
16
16
 
17
17
  def fractional_part_name(number)
18
18
  name = ""
19
- count_string = number.to_s.split('.')[1]
19
+ count_string = fractional_part_string(number).to_s.split('.')[1]
20
20
  count = count_string.to_i
21
21
  if count_string.size != count.to_s.size
22
22
  (count_string.size - count.to_s.size).times do
@@ -27,6 +27,20 @@ module Kabal
27
27
  natural_number_name(count)
28
28
  end
29
29
  end
30
+
31
+ def fractional_part_string(number)
32
+ "%.#{fractional_part_order(number)}f" % number
33
+ end
34
+
35
+ def fractional_part_order(number)
36
+ #FIXME find better way with whole 0 numbers
37
+ number_string = number.to_s
38
+ if number_string.include? "-"
39
+ number_string.split('-')[1].to_i
40
+ else
41
+ number_string.split('.')[1].length
42
+ end
43
+ end
30
44
  end
31
45
  end
32
46
  end
@@ -12,7 +12,7 @@ module Kabal
12
12
  end
13
13
 
14
14
  def whole_part_name(number)
15
- count = number.to_s.split('.')[0].to_i
15
+ count = number.floor
16
16
  feminine_natural_number_name(count) + " " + Declinations.name_with_declination(whole, count)
17
17
  end
18
18
 
@@ -38,9 +38,14 @@ module Kabal
38
38
  end
39
39
 
40
40
  def fractional_number_order(number)
41
- number.to_s.split('.')[1].length
41
+ #FIXME find better way with whole 0 numbers
42
+ number_string = number.to_s
43
+ if number_string.include? "-"
44
+ number_string.split('-')[1].to_i
45
+ else
46
+ number_string.split('.')[1].length
47
+ end
42
48
  end
43
-
44
49
  end
45
50
  end
46
51
  end
@@ -1,3 +1,3 @@
1
1
  module Kabal
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
  end
@@ -81,4 +81,8 @@ class DeutschTest < TestCase
81
81
  assert_equal "eins Komma null null null null null null null fünf", @deu.convert(1.00000005)
82
82
  assert_equal "minus eins Komma null null null null null null null fünf", @deu.convert(-1.00000005)
83
83
  end
84
+ def test_zero_point_zero_zero_zero_zero_zero_zero_zero_five
85
+ assert_equal "null Komma null null null null null null null fünf", @deu.convert(0.00000005)
86
+ assert_equal "minus null Komma null null null null null null null fünf", @deu.convert(-0.00000005)
87
+ end
84
88
  end
@@ -92,4 +92,8 @@ class EnglishTest < TestCase
92
92
  def test_big_number
93
93
  assert_equal "forty seven novemdecillion twenty six octodecillion one hundred fifty seven septendecillion eight hundred twenty five sexdecillion six hundred twenty seven quindecillion nine hundred eighty quattuordecillion seven hundred thirty three tredecillion four hundred thirty nine duodecillion two hundred twenty five undecillion eight hundred twenty three decillion three hundred fifty three nonillion twenty nine octillion six hundred fifty seven septillion seven hundred forty five sextillion five hundred forty four quintillion six hundred forty six quadrillion seven hundred sixty one trillion eight hundred ninety billion seventy four million two hundred forty four thousand and three", @eng.convert(47026157825627980733439225823353029657745544646761890074244003)
94
94
  end
95
+ def test_zero_point_zero_zero_zero_zero_zero_zero_zero_five
96
+ assert_equal "point zero zero zero zero zero zero zero five", @eng.convert(0.00000005)
97
+ assert_equal "minus point zero zero zero zero zero zero zero five", @eng.convert(-0.00000005)
98
+ end
95
99
  end
@@ -92,4 +92,8 @@ class RussianTest < TestCase
92
92
  def test_111000
93
93
  assert_equal "сто одиннадцать тысяч", @rus.convert(111000)
94
94
  end
95
+ def test_zero_point_zero_zero_zero_zero_zero_zero_zero_five
96
+ assert_equal "ноль целых пять стомиллионных", @rus.convert(0.00000005)
97
+ assert_equal "минус ноль целых пять стомиллионных", @rus.convert(-0.00000005)
98
+ end
95
99
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kabal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov