skanev-bulgarianize 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bulgarianize}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Stefan Kanev"]
@@ -18,11 +18,11 @@ module Bulgarianize
18
18
  HUNDREDS = %w[сто двеста триста четиристотин петстотин шестстотин седемстотин осемстотин деветстотин]
19
19
 
20
20
  def as_words(gender = :neuter)
21
- words_for(self.numeric, gender)
21
+ words_for(self.numeric.to_i, gender)
22
22
  end
23
23
 
24
24
  def as_leva
25
- levas, cents = self.numeric.floor, self.numeric.%(1).*(100).to_i
25
+ levas, cents = self.numeric.floor.to_i, self.numeric.%(1).*(100).to_i
26
26
  "#{words_for(levas, :male)} лева и #{cents} стотинки"
27
27
  end
28
28
 
@@ -3,90 +3,97 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  require 'bigdecimal'
4
4
 
5
5
  describe "NumberToWords" do
6
- it "should work with simple numbers less than 10" do
7
- %w{нула едно две три четири пет шест седем осем девет}.each_with_index do |words, number|
8
- number.bg.as_words.should == words
6
+ describe "#as_leva" do
7
+ it "should work with simple numbers less than 10" do
8
+ %w{нула едно две три четири пет шест седем осем девет}.each_with_index do |words, number|
9
+ number.bg.as_words.should == words
10
+ end
9
11
  end
10
- end
11
12
 
12
- it "should enable genders with numbers less than 10" do
13
- numbers = [
14
- %w{нула нула нула},
15
- %w{един една едно},
16
- %w{два две две},
17
- %w{три три три},
18
- ]
13
+ it "should enable genders with numbers less than 10" do
14
+ numbers = [
15
+ %w{нула нула нула},
16
+ %w{един една едно},
17
+ %w{два две две},
18
+ %w{три три три},
19
+ ]
19
20
 
20
- numbers.each_with_index do |names, number|
21
- [:male, :female, :neuter].zip(names) do |gender, name|
22
- number.bg.as_words(gender).should == name
21
+ numbers.each_with_index do |names, number|
22
+ [:male, :female, :neuter].zip(names) do |gender, name|
23
+ number.bg.as_words(gender).should == name
24
+ end
23
25
  end
24
26
  end
25
- end
26
27
 
27
- it "should work with numbers 11-19" do
28
- %w[единадесет дванадесет тринадесет четиринадесет петданесет шестнадесет седемнадесет осемнадесет деветнадесет].zip((11..19).to_a).each do |name, number|
29
- number.bg.as_words.should == name
28
+ it "should work with numbers 11-19" do
29
+ %w[единадесет дванадесет тринадесет четиринадесет петданесет шестнадесет седемнадесет осемнадесет деветнадесет].zip((11..19).to_a).each do |name, number|
30
+ number.bg.as_words.should == name
31
+ end
30
32
  end
31
- end
32
33
 
33
- it "should work with numbers dividable by 10" do
34
- %w[десет двадесет тридесет четиридесет петдесет шестдесет седемдесет осемдесет деветдесет].zip([10, 20, 30, 40, 50, 60, 70, 80, 90]).each do |name, number|
35
- number.bg.as_words.should == name
34
+ it "should work with numbers dividable by 10" do
35
+ %w[десет двадесет тридесет четиридесет петдесет шестдесет седемдесет осемдесет деветдесет].zip([10, 20, 30, 40, 50, 60, 70, 80, 90]).each do |name, number|
36
+ number.bg.as_words.should == name
37
+ end
36
38
  end
37
- end
38
39
 
39
- it "should work with numbers less than 100, not dividable by 10" do
40
- 42.bg.as_words.should == 'четиридесет и две'
41
- 97.bg.as_words.should == 'деветдесет и седем'
42
- 89.bg.as_words.should == 'осемдесет и девет'
43
- end
40
+ it "should work with numbers less than 100, not dividable by 10" do
41
+ 42.bg.as_words.should == 'четиридесет и две'
42
+ 97.bg.as_words.should == 'деветдесет и седем'
43
+ 89.bg.as_words.should == 'осемдесет и девет'
44
+ end
44
45
 
45
- it "should work with numbers less than 1000, divisable by 100" do
46
- %w[сто двеста триста четиристотин петстотин шестстотин седемстотин осемстотин деветстотин].zip([100, 200, 300, 400, 500, 600, 700, 800, 900]).each do |name, number|
47
- number.bg.as_words.should == name
46
+ it "should work with numbers less than 1000, divisable by 100" do
47
+ %w[сто двеста триста четиристотин петстотин шестстотин седемстотин осемстотин деветстотин].zip([100, 200, 300, 400, 500, 600, 700, 800, 900]).each do |name, number|
48
+ number.bg.as_words.should == name
49
+ end
48
50
  end
49
- end
50
51
 
51
- it "should work with numbers 100-1000, not dividable by 100" do
52
- 110.bg.as_words.should == 'сто и десет'
53
- 217.bg.as_words.should == 'двеста и седемнадесет'
54
- 420.bg.as_words.should == 'четиристотин и двадесет'
52
+ it "should work with numbers 100-1000, not dividable by 100" do
53
+ 110.bg.as_words.should == 'сто и десет'
54
+ 217.bg.as_words.should == 'двеста и седемнадесет'
55
+ 420.bg.as_words.should == 'четиристотин и двадесет'
55
56
 
56
- 123.bg.as_words.should == 'сто двадесет и три'
57
- end
57
+ 123.bg.as_words.should == 'сто двадесет и три'
58
+ end
58
59
 
59
- it "should work with numbers divisable with 1000" do
60
- 1_000.bg.as_words.should == 'хиляда'
61
- 2_000.bg.as_words.should == 'две хиляди'
62
- 5_000.bg.as_words.should == 'пет хиляди'
63
- 10_000.bg.as_words.should == 'десет хиляди'
64
- 13_000.bg.as_words.should == 'тринадесет хиляди'
65
- 28_000.bg.as_words.should == 'двадесет и осем хиляди'
66
- 100_000.bg.as_words.should == 'сто хиляди'
67
- 673_000.bg.as_words.should == 'шестстотин седемдесет и три хиляди'
68
- end
60
+ it "should work with numbers divisable with 1000" do
61
+ 1_000.bg.as_words.should == 'хиляда'
62
+ 2_000.bg.as_words.should == 'две хиляди'
63
+ 5_000.bg.as_words.should == 'пет хиляди'
64
+ 10_000.bg.as_words.should == 'десет хиляди'
65
+ 13_000.bg.as_words.should == 'тринадесет хиляди'
66
+ 28_000.bg.as_words.should == 'двадесет и осем хиляди'
67
+ 100_000.bg.as_words.should == 'сто хиляди'
68
+ 673_000.bg.as_words.should == 'шестстотин седемдесет и три хиляди'
69
+ end
69
70
 
70
- it "should work with numbers less than 1 000 000, not divisable with 1000" do
71
- 1_001.bg.as_words.should == 'хиляда и едно'
72
- 1_024.bg.as_words.should == 'хиляда двадесет и четири'
73
- 17_001.bg.as_words.should == 'седемнадесет хиляди и едно'
74
- 24_200.bg.as_words.should == 'двадесет и четири хиляди и двеста'
75
- 65_536.bg.as_words.should == 'шестдесет и пет хиляди петстотин тридесет и шест'
71
+ it "should work with numbers less than 1 000 000, not divisable with 1000" do
72
+ 1_001.bg.as_words.should == 'хиляда и едно'
73
+ 1_024.bg.as_words.should == 'хиляда двадесет и четири'
74
+ 17_001.bg.as_words.should == 'седемнадесет хиляди и едно'
75
+ 24_200.bg.as_words.should == 'двадесет и четири хиляди и двеста'
76
+ 65_536.bg.as_words.should == 'шестдесет и пет хиляди петстотин тридесет и шест'
76
77
 
77
- 123_456.bg.as_words.should == 'сто двадесет и три хиляди четиристотин петдесет и шест'
78
- end
78
+ 123_456.bg.as_words.should == 'сто двадесет и три хиляди четиристотин петдесет и шест'
79
+ end
79
80
 
80
- it "should work with millions" do
81
- 1_000_000.bg.as_words.should == 'един милион'
82
- 1_000_001.bg.as_words.should == 'един милион и едно'
83
- 2_000_200.bg.as_words.should == 'два милиона и двеста'
84
- 35_000_035.bg.as_words.should == 'тридесет и пет милиона тридесет и пет'
85
- 123_456_789.bg.as_words.should == 'сто двадесет и три милиона четиристотин петдесет и шест хиляди седемстотин осемдесет и девет'
86
- end
81
+ it "should work with millions" do
82
+ 1_000_000.bg.as_words.should == 'един милион'
83
+ 1_000_001.bg.as_words.should == 'един милион и едно'
84
+ 2_000_200.bg.as_words.should == 'два милиона и двеста'
85
+ 35_000_035.bg.as_words.should == 'тридесет и пет милиона тридесет и пет'
86
+ 123_456_789.bg.as_words.should == 'сто двадесет и три милиона четиристотин петдесет и шест хиляди седемстотин осемдесет и девет'
87
+ end
87
88
 
88
- it "should work with big numbers in male gender" do
89
- 121_121_121.bg.as_words(:male).should == 'сто двадесет и един милиона сто двадесет и една хиляди сто двадесет и един'
89
+ it "should work with big numbers in male gender" do
90
+ 121_121_121.bg.as_words(:male).should == 'сто двадесет и един милиона сто двадесет и една хиляди сто двадесет и един'
91
+ end
92
+
93
+ it "should work with the integer part only" do
94
+ BigDecimal("42").bg.as_words.should == 'четиридесет и две'
95
+ BigDecimal("42.10").bg.as_words.should == 'четиридесет и две'
96
+ end
90
97
  end
91
98
 
92
99
  it "should give numbers as levas" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skanev-bulgarianize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Kanev