kabal 0.2.14 → 0.2.15

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: 501779f1e454f2db85b91289089e709ab8682701
4
- data.tar.gz: aeac5f808d26d4cab88c1f2b5ee76c2d14a3a113
3
+ metadata.gz: 1ac2ea874e174e6bc64bfbacfc1969a2a569c490
4
+ data.tar.gz: bf93eea3f84e8a1f3b3439fef48fcad2ec48ef4c
5
5
  SHA512:
6
- metadata.gz: c011c155472b7e4805d9361036fc80db9b17f27f5493ce9782f4eebebc6ef3d5c0c8e53310850f1a4b49204309fa7c0159da93f33475ae6931819643d6bcc339
7
- data.tar.gz: 9e76695801c851494e90390f7220204414c0b93530d798655e6eae48c38abead1088004fb0a56f1150f14cd6f1b5127c8df53a53b0d31da6a3fd4ee8a4fb407d
6
+ metadata.gz: 22523b591f6ab9cd3717e3da54c4ba601d1f8b30c2d01ee0b352c80a7b3112b60c2796689ff7c71e7ef380be4dc128315cde0ac3947f8736fdbdf6e43fcfc932
7
+ data.tar.gz: 08e397d34caef6675084259ff71b90a2bf5e8e7089bcb1199691c203d1477afa5868bc3a3d232d676dfa1e8de9eb98d34edd80478cd37b1b76dc59969e98843c
data/README.md CHANGED
@@ -47,6 +47,7 @@ Supported Languages:
47
47
  * Negative Numbers
48
48
  * English
49
49
  * Natural Numbers { max 10 ** 63 }
50
+ * Negative Numbers
50
51
 
51
52
  *More languages will be added later.*
52
53
 
@@ -2,6 +2,13 @@ require 'kabal/languages/language'
2
2
 
3
3
  class Kabal::English < Kabal::Language
4
4
  def convert_number(number)
5
+ if need_minus? number
6
+ minus + " " + number_words(-number)
7
+ else
8
+ number_words number
9
+ end
10
+ end
11
+ def number_words(number)
5
12
  return single number if number >= 0 and number <= 19
6
13
  return two_words number if number >= 0 and number <= 99
7
14
  return three_words number if number >= 100 and number <= 999
@@ -89,5 +89,9 @@ module Kabal
89
89
  def no_supports?(number)
90
90
  (number % 1 != 0 and not supports_fractional?) or number_is_out_of_the_range?(number)
91
91
  end
92
+
93
+ def need_minus?(number)
94
+ number < 0
95
+ end
92
96
  end
93
97
  end
@@ -21,8 +21,4 @@ class Kabal::Russian < Kabal::Language
21
21
  return natural_number_name number.round if natural? number
22
22
  fractional_number_name number if fractional? number
23
23
  end
24
-
25
- def need_minus?(number)
26
- number < 0
27
- end
28
24
  end
@@ -1,3 +1,3 @@
1
1
  module Kabal
2
- VERSION = "0.2.14"
2
+ VERSION = "0.2.15"
3
3
  end
@@ -47,4 +47,10 @@ class EnglishTest < TestCase
47
47
  assert @eng.convert(number), number
48
48
  end
49
49
  end
50
+ def test_minus_one
51
+ assert_equal "minus one", @eng.convert(-1)
52
+ end
53
+ def test_minus_one_million_and_one_and_one_and_one
54
+ assert_equal "minus one hundred eleven million one hundred fifty thousand and twenty one", @eng.convert(-111150021)
55
+ end
50
56
  end
@@ -7,5 +7,5 @@ support:
7
7
  symbols: 16
8
8
  en:
9
9
  natural:
10
- min: "0"
10
+ min: "-(10 ** 66) + 1"
11
11
  max: "(10 ** 66) - 1"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kabal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.14
4
+ version: 0.2.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-21 00:00:00.000000000 Z
11
+ date: 2014-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler