kabal 1.0.0 → 1.0.1

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: de5e475e931da2b5e708213ce699c0e69cdcb1c5
4
- data.tar.gz: 8f37d26b3228d9b9471fff1397de6a1ed3dee356
3
+ metadata.gz: c320388dd7d3d224706c90a97fcace03b2c86131
4
+ data.tar.gz: 90f36dc3e091c41cc0d119f83a35b4b41aba328d
5
5
  SHA512:
6
- metadata.gz: a75d13edce6e537158b6ab2d9be8a5bbd46db205b9d693e851777fb4bb13fbcf0c6d9448ee4cf78425ad5e715666accf37e16025b373733d7650ce1b9847ec3c
7
- data.tar.gz: 61291e01e663a5b7a05daa5117df56b3fe0976681d61037ace697056f63d9e90d0bcc97770d21bbd2338b3891661e0375f39e8b303f2722548d010c40d8ecd87
6
+ metadata.gz: e4c81f9fb94f5ceb2c481ccd3df54d875c2f9002922503999878cafea214e6ffa18f926ffad1a0d180d4e555d266b6d7304b51b7340d8e77ce6961653dafe279
7
+ data.tar.gz: ebbb2434ceb4606f2419fee3483de0bf8a0b21b7d2501c795d79d042b305ae03cee211e2946bda5c37eddb6dd78bb91ac867c05168a980ff788959c077f545fd
@@ -2,7 +2,7 @@ module Kabal
2
2
  module DeutschRules
3
3
  module FractionalNumbers
4
4
  def fractional_number_name(number)
5
- whole_part_name(number) + ' ' + dot + ' ' + fractional_part_name(number)
5
+ join_with_spaces whole_part_name(number), dot, fractional_part_name(number)
6
6
  end
7
7
 
8
8
  def whole_part_name(number)
@@ -64,7 +64,7 @@ module Kabal
64
64
  end
65
65
 
66
66
  def number_with_space(number)
67
- @number_name = count_name(number) + ' ' + Declinations.name_with_declination(names[:ten_powers][number_order(number)], count(number)) + ' '
67
+ @number_name = join_with_spaces(count_name(number), Declinations.name_with_declination(names[:ten_powers][number_order(number)], count(number))) + space
68
68
  end
69
69
 
70
70
  def number_without_space(number)
@@ -3,9 +3,10 @@ module Kabal
3
3
  module FractionalNumbers
4
4
  def fractional_number_name(number)
5
5
  if whole_part_name(number) != ''
6
- whole_part_name(number) + ' ' + dot + ' ' + fractional_part_name(number)
6
+
7
+ join_with_spaces whole_part_name(number), dot, fractional_part_name(number)
7
8
  else
8
- dot + ' ' + fractional_part_name(number)
9
+ join_with_spaces dot, fractional_part_name(number)
9
10
  end
10
11
  end
11
12
 
@@ -8,15 +8,15 @@ module Kabal
8
8
  def two_words(number)
9
9
  return single number if number <= 19
10
10
  number_name = names[:two_words][number / 10]
11
- number_name += ' ' + single(number % 10) if (number % 10 != 0)
11
+ number_name += space + single(number % 10) if (number % 10 != 0)
12
12
  number_name
13
13
  end
14
14
 
15
15
  def three_words(number)
16
16
  return two_words number if number <= 99
17
- number_name = single(number / 100) + ' ' + names[:ten_powers][2]
18
- number_name += ' ' + two_words(number % 100) if number % 100 >= 10
19
- number_name += ' ' + names[:and] + ' ' + single(number % 100) if number % 100 < 10 && number % 100 != 0
17
+ number_name = join_with_spaces single(number / 100), names[:ten_powers][2]
18
+ number_name += space + two_words(number % 100) if number % 100 >= 10
19
+ number_name += space + join_with_spaces(names[:and], single(number % 100)) if number % 100 < 10 && number % 100 != 0
20
20
  number_name
21
21
  end
22
22
 
@@ -28,13 +28,13 @@ module Kabal
28
28
  end
29
29
 
30
30
  def count_name_with_order_name(number)
31
- three_words(count(number)) + ' ' + names[:ten_powers][number_order(number)]
31
+ join_with_spaces three_words(count(number)), names[:ten_powers][number_order(number)]
32
32
  end
33
33
 
34
34
  def less_thousands(number)
35
35
  return if number == 0
36
- @number_name += ' ' + names[:and] if number < 100
37
- @number_name += ' ' + three_words(number % 1000) unless number == 0
36
+ @number_name += space + names[:and] if number < 100
37
+ @number_name += space + three_words(number % 1000) unless number == 0
38
38
  end
39
39
  end
40
40
  end
@@ -31,7 +31,7 @@ module Kabal
31
31
  def number_name_with_zeros
32
32
  name = ''
33
33
  zeros_number.times do
34
- name += names[:single][0] + ' '
34
+ name += names[:single][0] + space
35
35
  end
36
36
  name
37
37
  end
@@ -12,7 +12,7 @@ module Kabal
12
12
  if @number_name.nil?
13
13
  @number_name = count_name_with_order_name number
14
14
  elsif count(number) != 0
15
- @number_name += ' ' + count_name_with_order_name(number)
15
+ @number_name += space + count_name_with_order_name(number)
16
16
  end
17
17
  end
18
18
  end
@@ -23,7 +23,7 @@ module Kabal
23
23
  def convert_number(number)
24
24
  @number_name = nil
25
25
  if need_minus? number
26
- minus + ' ' + number_words(-number)
26
+ join_with_spaces minus, number_words(-number)
27
27
  else
28
28
  number_words number
29
29
  end
@@ -123,5 +123,13 @@ module Kabal
123
123
  def need_minus?(number)
124
124
  number < 0
125
125
  end
126
+
127
+ def space
128
+ ' '
129
+ end
130
+
131
+ def join_with_spaces(*words)
132
+ words.to_a.join space
133
+ end
126
134
  end
127
135
  end
@@ -2,18 +2,18 @@ module Kabal
2
2
  module RussianRules
3
3
  module FractionalNumbers
4
4
  def fractional_number_name(number)
5
- whole_part_name(number) + ' ' + fractional_part_name(number)
5
+ join_with_spaces whole_part_name(number), fractional_part_name(number)
6
6
  end
7
7
 
8
8
  def fractional_part_name(number)
9
9
  fractional_part = (number % 1).round(fractional_part_order(number))
10
10
  fractional_order = ((fractional_part) * (10**fractional_part_order(number))).to_s.split('.')[0].to_i
11
- feminine_natural_number_name(fractional_order, true) + ' ' + Declinations.name_with_declination(fractional_ten_powers_name(number), fractional_part)
11
+ join_with_spaces feminine_natural_number_name(fractional_order, true), Declinations.name_with_declination(fractional_ten_powers_name(number), fractional_part)
12
12
  end
13
13
 
14
14
  def whole_part_name(number)
15
15
  count = number.floor
16
- feminine_natural_number_name(count) + ' ' + Declinations.name_with_declination(whole, count)
16
+ join_with_spaces feminine_natural_number_name(count), Declinations.name_with_declination(whole, count)
17
17
  end
18
18
 
19
19
  def fractional_ten_powers_name(number)
@@ -24,15 +24,15 @@ module Kabal
24
24
  def two_words(number, this_is_end = true)
25
25
  return single(number, this_is_end) if number <= 19
26
26
  number_name = names[:two_words][number / 10]
27
- number_name += ' ' + single(number % 10, this_is_end) if (number % 10 != 0)
27
+ number_name += space + single(number % 10, this_is_end) if (number % 10 != 0)
28
28
  number_name
29
29
  end
30
30
 
31
31
  def three_words(number, this_is_end = true)
32
32
  return two_words(number, this_is_end) if number / 100 == 0
33
33
  number_name = names[:three_words][number / 100]
34
- return number_name += ' ' + two_words(number % 100, this_is_end) if (number % 100 >= 20)
35
- return number_name += ' ' + single(number % 100, this_is_end) if (number % 100 != 0)
34
+ return number_name += space + two_words(number % 100, this_is_end) if (number % 100 >= 20)
35
+ return number_name += space + single(number % 100, this_is_end) if (number % 100 != 0)
36
36
  number_name
37
37
  end
38
38
 
@@ -49,7 +49,7 @@ module Kabal
49
49
  end
50
50
 
51
51
  def less_thousands(number)
52
- @number_name += ' ' + three_words(number % 1000) unless number == 0
52
+ @number_name += space + three_words(number % 1000) unless number == 0
53
53
  end
54
54
 
55
55
  def count_name(number)
@@ -62,7 +62,7 @@ module Kabal
62
62
  end
63
63
 
64
64
  def count_name_with_order_name(number)
65
- count_name(number) + ' ' + Declinations.name_with_declination(names[:ten_powers][number_order(number)], count(number))
65
+ join_with_spaces count_name(number), Declinations.name_with_declination(names[:ten_powers][number_order(number)], count(number))
66
66
  end
67
67
  end
68
68
  end
data/lib/kabal/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kabal
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
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: 1.0.0
4
+ version: 1.0.1
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-08-05 00:00:00.000000000 Z
11
+ date: 2014-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler