wintr 0.2.1 → 1.0.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 61ab5b7f12b66cddc01c68cf6ae80a291f647468
4
+ data.tar.gz: 94c81209b089347fa155a581983dc1ad875e7bdb
5
+ SHA512:
6
+ metadata.gz: 3943a4886fd78ea55786cff45dab2cffc6792652dd986813d70143177d4ef8d500d38fa0c3a97084ebb6d8f505662bc449c399dca419c55676e5e30424b218ca
7
+ data.tar.gz: d1f58301a5e4780080b8554b70b432f02bfb69001f1916dc6dbc38518271295439ddfe4ea72decd140d2e6d210400a18f6b9f914abce5a3b92808c9dddeb4171
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # Wintr
2
+ [![Gem Version](https://badge.fury.io/rb/wintr.png)](http://badge.fury.io/rb/wintr)
2
3
 
3
- A number to word converter. Integers up to a maximum of 999 duotrigintillion (American) can be handled! See Russ Rowlett's discussion on [Names for Large Numbers](http://www.unc.edu/~rowlett/units/large.html)
4
+ A number to word converter.
5
+
6
+ Integers up to a maximum of 999 duotrigintillion (American) can be handled! See Russ Rowlett's discussion on [Names for Large Numbers](http://www.unc.edu/~rowlett/units/large.html)
4
7
 
5
8
  ## Install
6
9
 
@@ -8,17 +11,15 @@ A number to word converter. Integers up to a maximum of 999 duotrigintillion (A
8
11
 
9
12
  ## Usage
10
13
 
11
- Wintr::Number.new(0).to_w
14
+ Wintr::Number.new(0).to_s
12
15
  # => "zero"
13
16
 
14
- Wintr::Number.new(9*9).to_w
17
+ Wintr::Number.new(9*9).to_s
15
18
  # => "eighty one"
16
19
 
17
- Wintr::Number.new(951_213_724).to_w
20
+ Wintr::Number.new(951_213_724).to_s
18
21
  # => "nine hundred and fifty one million two hundred and thirteen thousand seven hundred and twenty four"
19
22
 
20
23
  ## Licence
21
24
 
22
25
  Released under the MIT License. See the [LICENCE.md](https://github.com/headleyra/wintr/blob/master/LICENCE.md) file for further details.
23
-
24
-
@@ -8,14 +8,14 @@ module Wintr
8
8
  @digits = digits
9
9
  end
10
10
 
11
- def to_w
11
+ def to_s
12
12
  case @digits.size
13
13
  when 1
14
- OneDigitGroup.new(@digits[0]).to_w
14
+ OneDigitGroup.new(@digits[0]).to_s
15
15
  when 2
16
- TwoDigitGroup.new(@digits[0], @digits[1]).to_w
16
+ TwoDigitGroup.new(@digits[0], @digits[1]).to_s
17
17
  when 3
18
- ThreeDigitGroup.new(@digits[0], @digits[1], @digits[2]).to_w
18
+ ThreeDigitGroup.new(@digits[0], @digits[1], @digits[2]).to_s
19
19
  end
20
20
  end
21
21
  end
data/lib/wintr/number.rb CHANGED
@@ -7,7 +7,7 @@ module Wintr
7
7
  @number = number
8
8
  end
9
9
 
10
- def to_w
10
+ def to_s
11
11
  return 'zero' if @number == 0
12
12
 
13
13
  word_array = []
@@ -16,10 +16,10 @@ module Wintr
16
16
 
17
17
  until digit_array == [] do
18
18
  digit_group = digit_array.pop(3)
19
- word_array.unshift(WeightedDigitGroup.new(digit_group, power_of_thousand).to_w)
19
+ word_array.unshift(WeightedDigitGroup.new(digit_group, power_of_thousand).to_s)
20
20
  power_of_thousand += 1
21
21
  end
22
- WordArray.new(word_array).to_w
22
+ WordArray.new(word_array).to_s
23
23
  end
24
24
  end
25
25
  end
@@ -12,12 +12,12 @@ module Wintr
12
12
  '8' => 'eight',
13
13
  '9' => 'nine'
14
14
  }
15
-
15
+
16
16
  def initialize(units)
17
17
  @units = units
18
18
  end
19
-
20
- def to_w
19
+
20
+ def to_s
21
21
  UNITS[@units]
22
22
  end
23
23
  end
@@ -40,7 +40,7 @@ module Wintr
40
40
  @power = power
41
41
  end
42
42
 
43
- def to_w
43
+ def to_s
44
44
  POWER[@power] || ''
45
45
  end
46
46
  end
@@ -4,16 +4,16 @@ module Wintr
4
4
  @hundreds, @tens, @units = hundreds, tens, units
5
5
  end
6
6
 
7
- def to_w
7
+ def to_s
8
8
  word_array = []
9
9
  if @hundreds == '0' && @tens == '0' && @units == '0'
10
10
  ''
11
11
  else
12
- word_array << OneDigitGroup.new(@hundreds).to_w
12
+ word_array << OneDigitGroup.new(@hundreds).to_s
13
13
  word_array << 'hundred' if @hundreds != '0'
14
14
  word_array << 'and' unless @tens == '0' && @units == '0'
15
- word_array << TwoDigitGroup.new(@tens, @units).to_w
16
- WordArray.new(word_array).to_w
15
+ word_array << TwoDigitGroup.new(@tens, @units).to_s
16
+ WordArray.new(word_array).to_s
17
17
  end
18
18
  end
19
19
  end
@@ -27,7 +27,7 @@ module Wintr
27
27
  @tens, @units = tens, units
28
28
  end
29
29
 
30
- def to_w
30
+ def to_s
31
31
  word_array = []
32
32
 
33
33
  if @tens == '1'
@@ -36,8 +36,8 @@ module Wintr
36
36
  ''
37
37
  else
38
38
  word_array << TENS[@tens]
39
- word_array << OneDigitGroup.new(@units).to_w
40
- WordArray.new(word_array).to_w
39
+ word_array << OneDigitGroup.new(@units).to_s
40
+ WordArray.new(word_array).to_s
41
41
  end
42
42
  end
43
43
  end
data/lib/wintr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Wintr
2
- VERSION = '0.2.1'
2
+ VERSION = '1.0.0'
3
3
  end
@@ -8,10 +8,10 @@ module Wintr
8
8
  @digit_group, @power_of_thousand = digit_group, power_of_thousand
9
9
  end
10
10
 
11
- def to_w
12
- base_digit_group_in_words = DigitGroup.new(@digit_group).to_w
13
- power_of_thousand_in_words = PowerOfThousand.new(@power_of_thousand).to_w if base_digit_group_in_words != ''
14
- WordArray.new([base_digit_group_in_words, power_of_thousand_in_words]).to_w
11
+ def to_s
12
+ base_digit_group_in_words = DigitGroup.new(@digit_group).to_s
13
+ power_of_thousand_in_words = PowerOfThousand.new(@power_of_thousand).to_s if base_digit_group_in_words != ''
14
+ WordArray.new([base_digit_group_in_words, power_of_thousand_in_words]).to_s
15
15
  end
16
16
  end
17
17
  end
@@ -4,7 +4,7 @@ module Wintr
4
4
  @array = array
5
5
  end
6
6
 
7
- def to_w
7
+ def to_s
8
8
  @array.join(' ').squeeze(' ').strip
9
9
  end
10
10
  end
@@ -3,27 +3,26 @@ require 'spec_helper'
3
3
  module Wintr
4
4
 
5
5
  describe DigitGroup do
6
- describe "#to_w" do
6
+ describe "#to_s" do
7
7
  it "should convert 0 to empty string" do
8
- DigitGroup.new(['0']).to_w.should == ''
8
+ DigitGroup.new(['0']).to_s.should == ''
9
9
  end
10
10
  it "should convert 9" do
11
- DigitGroup.new(['9']).to_w.should == 'nine'
11
+ DigitGroup.new(['9']).to_s.should == 'nine'
12
12
  end
13
13
  it "should convert 10" do
14
- DigitGroup.new(%w[1 0]).to_w.should == 'ten'
14
+ DigitGroup.new(%w[1 0]).to_s.should == 'ten'
15
15
  end
16
16
  it "should convert 19" do
17
- DigitGroup.new(%w[1 9]).to_w.should == 'nineteen'
17
+ DigitGroup.new(%w[1 9]).to_s.should == 'nineteen'
18
18
  end
19
19
  it "should convert 20" do
20
- DigitGroup.new(%w[2 0]).to_w.should == 'twenty'
20
+ DigitGroup.new(%w[2 0]).to_s.should == 'twenty'
21
21
  end
22
22
  it "should convert 702" do
23
- DigitGroup.new(%w[7 0 2]).to_w.should == 'seven hundred and two'
23
+ DigitGroup.new(%w[7 0 2]).to_s.should == 'seven hundred and two'
24
24
  end
25
25
  end
26
26
  end
27
27
 
28
28
  end
29
-
@@ -1,183 +1,73 @@
1
1
  require 'spec_helper'
2
2
 
3
- module Wintr
3
+ CONVERSIONS = {
4
+ 1 => 'one',
5
+ 27 => 'twenty seven',
6
+ 115 => 'one hundred and fifteen',
7
+ 3_700 => 'three thousand seven hundred',
8
+ 56_945_781 => 'fifty six million nine hundred and forty five thousand seven hundred and eighty one',
9
+ 126_000_010 => 'one hundred and twenty six million and ten',
10
+ 999_999_999 => 'nine hundred and ninety nine million nine hundred and ninety nine thousand nine hundred and ninety nine',
4
11
 
5
- describe Number do
6
- describe "#to_w" do
7
- it "should convert 1" do
8
- Number.new(1).to_w.should == 'one'
9
- end
10
- it "should convert 27" do
11
- Number.new(27).to_w.should == 'twenty seven'
12
- end
13
- it "should convert 115" do
14
- Number.new(115).to_w.should == 'one hundred and fifteen'
15
- end
16
- it "should convert 3,700" do
17
- Number.new(3_700).to_w.should == 'three thousand seven hundred'
18
- end
19
- it "should convert 56,945,781" do
20
- Number.new(56_945_781).to_w.should == 'fifty six million nine hundred and forty five thousand seven hundred and eighty one'
21
- end
22
- it "should convert 126,000,010" do
23
- Number.new(126_000_010).to_w.should == 'one hundred and twenty six million and ten'
24
- end
25
- it "should convert 999,999,999" do
26
- Number.new(999_999_999).to_w.should == 'nine hundred and ninety nine million nine hundred and ninety nine thousand nine hundred and ninety nine'
27
- end
12
+ 9 => 'nine',
13
+ 10 => 'ten',
14
+ 11 => 'eleven',
15
+ 12 => 'twelve',
16
+ 13 => 'thirteen',
17
+ 14 => 'fourteen',
18
+ 15 => 'fifteen',
19
+ 16 => 'sixteen',
20
+ 17 => 'seventeen',
21
+ 18 => 'eighteen',
22
+ 19 => 'nineteen',
23
+ 20 => 'twenty',
24
+ 21 => 'twenty one',
28
25
 
29
- # extra tests
30
- it "should convert 9" do
31
- Number.new(9).to_w.should == 'nine'
32
- end
33
- it "should convert 10" do
34
- Number.new(10).to_w.should == 'ten'
35
- end
36
- it "should convert 11" do
37
- Number.new(11).to_w.should == 'eleven'
38
- end
39
- it "should convert 12" do
40
- Number.new(12).to_w.should == 'twelve'
41
- end
42
- it "should convert 13" do
43
- Number.new(13).to_w.should == 'thirteen'
44
- end
45
- it "should convert 14" do
46
- Number.new(14).to_w.should == 'fourteen'
47
- end
48
- it "should convert 15" do
49
- Number.new(15).to_w.should == 'fifteen'
50
- end
51
- it "should convert 16" do
52
- Number.new(16).to_w.should == 'sixteen'
53
- end
54
- it "should convert 17" do
55
- Number.new(17).to_w.should == 'seventeen'
56
- end
57
- it "should convert 18" do
58
- Number.new(18).to_w.should == 'eighteen'
59
- end
60
- it "should convert 19" do
61
- Number.new(19).to_w.should == 'nineteen'
62
- end
63
- it "should convert 20" do
64
- Number.new(20).to_w.should == 'twenty'
65
- end
66
- it "should convert 21" do
67
- Number.new(21).to_w.should == 'twenty one'
68
- end
69
- it "should convert 99" do
70
- Number.new(99).to_w.should == 'ninety nine'
71
- end
72
- it "should convert 100" do
73
- Number.new(100).to_w.should == 'one hundred'
74
- end
75
- it "should convert 102" do
76
- Number.new(102).to_w.should == 'one hundred and two'
77
- end
78
- it "should convert 3,000" do
79
- Number.new(3000).to_w.should == 'three thousand'
80
- end
81
- it "should convert 3,007" do
82
- Number.new(3007).to_w.should == 'three thousand and seven'
83
- end
26
+ 99 => 'ninety nine',
27
+ 100 => 'one hundred',
28
+ 102 => 'one hundred and two',
29
+ 3000 => 'three thousand',
30
+ 3007 => 'three thousand and seven',
84
31
 
85
- # silly big number testing starts here :-)
86
- it "should convert billions" do
87
- Number.new(9 * (10**9) + 9).to_w.should == 'nine billion and nine'
88
- end
89
- it "should convert trillions" do
90
- Number.new(12 * (10**12) + 12).to_w.should == 'twelve trillion and twelve'
91
- end
92
- it "should convert quadrillions" do
93
- Number.new(15 * (10**15) + 15).to_w.should == 'fifteen quadrillion and fifteen'
94
- end
95
- it "should convert quintillions" do
96
- Number.new(18 * (10**18) + 18).to_w.should == 'eighteen quintillion and eighteen'
97
- end
98
- it "should convert sextillions" do
99
- Number.new(21 * (10**21) + 21).to_w.should == 'twenty one sextillion and twenty one'
100
- end
101
- it "should convert septillions" do
102
- Number.new(24 * (10**24) + 24).to_w.should == 'twenty four septillion and twenty four'
103
- end
104
- it "should convert octillions" do
105
- Number.new(27 * (10**27) + 27).to_w.should == 'twenty seven octillion and twenty seven'
106
- end
107
- it "should convert nonillions" do
108
- Number.new(30 * (10**30) + 30).to_w.should == 'thirty nonillion and thirty'
109
- end
110
- it "should convert decillion" do
111
- Number.new(33 * (10**33) + 33).to_w.should == 'thirty three decillion and thirty three'
112
- end
113
- it "should convert undecillions" do
114
- Number.new(36 * (10**36) + 36).to_w.should == 'thirty six undecillion and thirty six'
115
- end
116
- it "should convert duodecillions" do
117
- Number.new(39 * (10**39) + 39).to_w.should == 'thirty nine duodecillion and thirty nine'
118
- end
119
- it "should convert tredecillions" do
120
- Number.new(42 * (10**42) + 42).to_w.should == 'forty two tredecillion and forty two'
121
- end
122
- it "should convert quattuordecillions" do
123
- Number.new(45 * (10**45) + 45).to_w.should == 'forty five quattuordecillion and forty five'
124
- end
125
- it "should convert quindecillions" do
126
- Number.new(48 * (10**48) + 48).to_w.should == 'forty eight quindecillion and forty eight'
127
- end
128
- it "should convert sexdecillions" do
129
- Number.new(51 * (10**51) + 51).to_w.should == 'fifty one sexdecillion and fifty one'
130
- end
131
- it "should convert septendecillions" do
132
- Number.new(54 * (10**54) + 54).to_w.should == 'fifty four septendecillion and fifty four'
133
- end
134
- it "should convert octodecillions" do
135
- Number.new(57 * (10**57) + 57).to_w.should == 'fifty seven octodecillion and fifty seven'
136
- end
137
- it "should convert novemdecillions" do
138
- Number.new(60 * (10**60) + 60).to_w.should == 'sixty novemdecillion and sixty'
139
- end
140
- it "should convert vigintillions" do
141
- Number.new(63 * (10**63) + 63).to_w.should == 'sixty three vigintillion and sixty three'
142
- end
143
- it "should convert unvigintillions" do
144
- Number.new(66 * (10**66) + 66).to_w.should == 'sixty six unvigintillion and sixty six'
145
- end
146
- it "should convert duovigintillions" do
147
- Number.new(69 * (10**69) + 69).to_w.should == 'sixty nine duovigintillion and sixty nine'
148
- end
149
- it "should convert trevigintillions" do
150
- Number.new(72 * (10**72) + 72).to_w.should == 'seventy two trevigintillion and seventy two'
151
- end
152
- it "should convert quattuorvigintillions" do
153
- Number.new(75 * (10**75) + 75).to_w.should == 'seventy five quattuorvigintillion and seventy five'
154
- end
155
- it "should convert quinvigintillions" do
156
- Number.new(78 * (10**78) + 78).to_w.should == 'seventy eight quinvigintillion and seventy eight'
157
- end
158
- it "should convert sexvigintillions" do
159
- Number.new(81 * (10**81) + 81).to_w.should == 'eighty one sexvigintillion and eighty one'
160
- end
161
- it "should convert septenvigintillions" do
162
- Number.new(84 * (10**84) + 84).to_w.should == 'eighty four septenvigintillion and eighty four'
163
- end
164
- it "should convert octovigintillions" do
165
- Number.new(87 * (10**87) + 87).to_w.should == 'eighty seven octovigintillion and eighty seven'
166
- end
167
- it "should convert novemvigintillions" do
168
- Number.new(90 * (10**90) + 90).to_w.should == 'ninety novemvigintillion and ninety'
169
- end
170
- it "should convert trigintillions" do
171
- Number.new(93 * (10**93) + 93).to_w.should == 'ninety three trigintillion and ninety three'
172
- end
173
- it "should convert untrigintillions" do
174
- Number.new(96 * (10**96) + 96).to_w.should == 'ninety six untrigintillion and ninety six'
175
- end
176
- it "should convert duotrigintillions" do
177
- Number.new(99 * (10**99) + 99).to_w.should == 'ninety nine duotrigintillion and ninety nine'
32
+ 9 * (10**9) + 9 => 'nine billion and nine',
33
+ 12 * (10**12) + 12 => 'twelve trillion and twelve',
34
+ 15 * (10**15) + 15 => 'fifteen quadrillion and fifteen',
35
+ 18 * (10**18) + 18 => 'eighteen quintillion and eighteen',
36
+ 21 * (10**21) + 21 => 'twenty one sextillion and twenty one',
37
+ 24 * (10**24) + 24 => 'twenty four septillion and twenty four',
38
+ 27 * (10**27) + 27 => 'twenty seven octillion and twenty seven',
39
+ 30 * (10**30) + 30 => 'thirty nonillion and thirty',
40
+ 33 * (10**33) + 33 => 'thirty three decillion and thirty three',
41
+ 36 * (10**36) + 36 => 'thirty six undecillion and thirty six',
42
+ 39 * (10**39) + 39 => 'thirty nine duodecillion and thirty nine',
43
+ 42 * (10**42) + 42 => 'forty two tredecillion and forty two',
44
+ 45 * (10**45) + 45 => 'forty five quattuordecillion and forty five',
45
+ 48 * (10**48) + 48 => 'forty eight quindecillion and forty eight',
46
+ 51 * (10**51) + 51 => 'fifty one sexdecillion and fifty one',
47
+ 54 * (10**54) + 54 => 'fifty four septendecillion and fifty four',
48
+ 57 * (10**57) + 57 => 'fifty seven octodecillion and fifty seven',
49
+ 60 * (10**60) + 60 => 'sixty novemdecillion and sixty',
50
+ 63 * (10**63) + 63 => 'sixty three vigintillion and sixty three',
51
+ 66 * (10**66) + 66 => 'sixty six unvigintillion and sixty six',
52
+ 69 * (10**69) + 69 => 'sixty nine duovigintillion and sixty nine',
53
+ 72 * (10**72) + 72 => 'seventy two trevigintillion and seventy two',
54
+ 75 * (10**75) + 75 => 'seventy five quattuorvigintillion and seventy five',
55
+ 78 * (10**78) + 78 => 'seventy eight quinvigintillion and seventy eight',
56
+ 81 * (10**81) + 81 => 'eighty one sexvigintillion and eighty one',
57
+ 84 * (10**84) + 84 => 'eighty four septenvigintillion and eighty four',
58
+ 87 * (10**87) + 87 => 'eighty seven octovigintillion and eighty seven',
59
+ 90 * (10**90) + 90 => 'ninety novemvigintillion and ninety',
60
+ 93 * (10**93) + 93 => 'ninety three trigintillion and ninety three',
61
+ 96 * (10**96) + 96 => 'ninety six untrigintillion and ninety six',
62
+ 99 * (10**99) + 99 => 'ninety nine duotrigintillion and ninety nine'
63
+ }
64
+
65
+ describe Wintr::Number do
66
+ describe "#to_s" do
67
+ CONVERSIONS.each do |integer, word|
68
+ it "converts #{integer}" do
69
+ Wintr::Number.new(integer).to_s.should == word
178
70
  end
179
71
  end
180
72
  end
181
-
182
73
  end
183
-
@@ -1,39 +1,26 @@
1
1
  require 'spec_helper'
2
2
 
3
- module Wintr
4
- describe OneDigitGroup do
5
- describe "#to_w" do
6
- it "should convert 0 to empty string" do
7
- OneDigitGroup.new('0').to_w.should == ''
8
- end
9
- it "should convert 1" do
10
- OneDigitGroup.new('1').to_w.should == 'one'
11
- end
12
- it "should convert 2" do
13
- OneDigitGroup.new('2').to_w.should == 'two'
14
- end
15
- it "should convert 3" do
16
- OneDigitGroup.new('3').to_w.should == 'three'
17
- end
18
- it "should convert 4" do
19
- OneDigitGroup.new('4').to_w.should == 'four'
20
- end
21
- it "should convert 5" do
22
- OneDigitGroup.new('5').to_w.should == 'five'
23
- end
24
- it "should convert 6" do
25
- OneDigitGroup.new('6').to_w.should == 'six'
26
- end
27
- it "should convert 7" do
28
- OneDigitGroup.new('7').to_w.should == 'seven'
29
- end
30
- it "should convert 8" do
31
- OneDigitGroup.new('8').to_w.should == 'eight'
32
- end
33
- it "should convert 9" do
34
- OneDigitGroup.new('9').to_w.should == 'nine'
3
+ def single_digits
4
+ {
5
+ '0' => '',
6
+ '1' => 'one',
7
+ '2' => 'two',
8
+ '3' => 'three',
9
+ '4' => 'four',
10
+ '5' => 'five',
11
+ '6' => 'six',
12
+ '7' => 'seven',
13
+ '8' => 'eight',
14
+ '9' => 'nine'
15
+ }
16
+ end
17
+
18
+ describe Wintr::OneDigitGroup do
19
+ describe "#to_s" do
20
+ single_digits.each do |digit_string, word|
21
+ it "converts #{digit_string} to #{word}" do
22
+ Wintr::OneDigitGroup.new(digit_string).to_s.should == word
35
23
  end
36
24
  end
37
25
  end
38
26
  end
39
-
@@ -3,18 +3,18 @@ require 'spec_helper'
3
3
  module Wintr
4
4
 
5
5
  describe PowerOfThousand do
6
- describe "#to_w" do
6
+ describe "#to_s" do
7
7
  it "should convert 0 to empty string" do
8
- PowerOfThousand.new(0).to_w.should == ''
8
+ PowerOfThousand.new(0).to_s.should == ''
9
9
  end
10
10
  it "should convert 1 into it's power-of-a-thousand equivalent" do
11
- PowerOfThousand.new(1).to_w.should == 'thousand'
11
+ PowerOfThousand.new(1).to_s.should == 'thousand'
12
12
  end
13
13
  it "should convert 2 into it's power-of-a-thousand equivalent" do
14
- PowerOfThousand.new(2).to_w.should == 'million'
14
+ PowerOfThousand.new(2).to_s.should == 'million'
15
15
  end
16
16
  it "should convert rubbish input into empty string" do
17
- PowerOfThousand.new('foo').to_w.should == ''
17
+ PowerOfThousand.new('foo').to_s.should == ''
18
18
  end
19
19
  end
20
20
  end
@@ -2,21 +2,21 @@ require 'spec_helper'
2
2
 
3
3
  module Wintr
4
4
  describe ThreeDigitGroup do
5
- describe "#to_w" do
5
+ describe "#to_s" do
6
6
  it "should convert 000 to empty string" do
7
- ThreeDigitGroup.new('0', '0', '0').to_w.should == ''
7
+ ThreeDigitGroup.new('0', '0', '0').to_s.should == ''
8
8
  end
9
9
  it "should convert 101" do
10
- ThreeDigitGroup.new('1', '0', '1').to_w.should == 'one hundred and one'
10
+ ThreeDigitGroup.new('1', '0', '1').to_s.should == 'one hundred and one'
11
11
  end
12
12
  it "should convert 900" do
13
- ThreeDigitGroup.new('9', '0', '0').to_w.should == 'nine hundred'
13
+ ThreeDigitGroup.new('9', '0', '0').to_s.should == 'nine hundred'
14
14
  end
15
15
  it "should convert 070" do
16
- ThreeDigitGroup.new('0', '7', '0').to_w.should == 'and seventy'
16
+ ThreeDigitGroup.new('0', '7', '0').to_s.should == 'and seventy'
17
17
  end
18
18
  it "should convert 005" do
19
- ThreeDigitGroup.new('0', '0', '5').to_w.should == 'and five'
19
+ ThreeDigitGroup.new('0', '0', '5').to_s.should == 'and five'
20
20
  end
21
21
  end
22
22
  end
@@ -2,57 +2,57 @@ require 'spec_helper'
2
2
 
3
3
  module Wintr
4
4
  describe TwoDigitGroup do
5
- describe "#to_w" do
5
+ describe "#to_s" do
6
6
  it "should convert 00 to empty string" do
7
- TwoDigitGroup.new('0', '0').to_w.should == ''
7
+ TwoDigitGroup.new('0', '0').to_s.should == ''
8
8
  end
9
9
  it "should convert 01 to one" do
10
- TwoDigitGroup.new('0', '1').to_w.should == 'one'
10
+ TwoDigitGroup.new('0', '1').to_s.should == 'one'
11
11
  end
12
12
  it "should convert 09 to nine" do
13
- TwoDigitGroup.new('0', '9').to_w.should == 'nine'
13
+ TwoDigitGroup.new('0', '9').to_s.should == 'nine'
14
14
  end
15
15
  it "should convert 10" do
16
- TwoDigitGroup.new('1', '0').to_w.should == 'ten'
16
+ TwoDigitGroup.new('1', '0').to_s.should == 'ten'
17
17
  end
18
18
  it "should convert 11" do
19
- TwoDigitGroup.new('1', '1').to_w.should == 'eleven'
19
+ TwoDigitGroup.new('1', '1').to_s.should == 'eleven'
20
20
  end
21
21
  it "should convert 12" do
22
- TwoDigitGroup.new('1', '2').to_w.should == 'twelve'
22
+ TwoDigitGroup.new('1', '2').to_s.should == 'twelve'
23
23
  end
24
24
  it "should convert 13" do
25
- TwoDigitGroup.new('1', '3').to_w.should == 'thirteen'
25
+ TwoDigitGroup.new('1', '3').to_s.should == 'thirteen'
26
26
  end
27
27
  it "should convert 14" do
28
- TwoDigitGroup.new('1', '4').to_w.should == 'fourteen'
28
+ TwoDigitGroup.new('1', '4').to_s.should == 'fourteen'
29
29
  end
30
30
  it "should convert 15" do
31
- TwoDigitGroup.new('1', '5').to_w.should == 'fifteen'
31
+ TwoDigitGroup.new('1', '5').to_s.should == 'fifteen'
32
32
  end
33
33
  it "should convert 16" do
34
- TwoDigitGroup.new('1', '6').to_w.should == 'sixteen'
34
+ TwoDigitGroup.new('1', '6').to_s.should == 'sixteen'
35
35
  end
36
36
  it "should convert 17" do
37
- TwoDigitGroup.new('1', '7').to_w.should == 'seventeen'
37
+ TwoDigitGroup.new('1', '7').to_s.should == 'seventeen'
38
38
  end
39
39
  it "should convert 18" do
40
- TwoDigitGroup.new('1', '8').to_w.should == 'eighteen'
40
+ TwoDigitGroup.new('1', '8').to_s.should == 'eighteen'
41
41
  end
42
42
  it "should convert 19" do
43
- TwoDigitGroup.new('1', '9').to_w.should == 'nineteen'
43
+ TwoDigitGroup.new('1', '9').to_s.should == 'nineteen'
44
44
  end
45
45
  it "should convert 20" do
46
- TwoDigitGroup.new('2', '0').to_w.should == 'twenty'
46
+ TwoDigitGroup.new('2', '0').to_s.should == 'twenty'
47
47
  end
48
48
  it "should convert 21" do
49
- TwoDigitGroup.new('2', '1').to_w.should == 'twenty one'
49
+ TwoDigitGroup.new('2', '1').to_s.should == 'twenty one'
50
50
  end
51
51
  it "should convert 77" do
52
- TwoDigitGroup.new('7', '7').to_w.should == 'seventy seven'
52
+ TwoDigitGroup.new('7', '7').to_s.should == 'seventy seven'
53
53
  end
54
54
  it "should convert 99" do
55
- TwoDigitGroup.new('9', '9').to_w.should == 'ninety nine'
55
+ TwoDigitGroup.new('9', '9').to_s.should == 'ninety nine'
56
56
  end
57
57
  end
58
58
  end
@@ -2,23 +2,22 @@ require 'spec_helper'
2
2
 
3
3
  module Wintr
4
4
  describe WeightedDigitGroup do
5
- describe "#to_w" do
5
+ describe "#to_s" do
6
6
  it "should should convert 23 thousand" do
7
- WeightedDigitGroup.new(%w[2 1], 1).to_w.should == 'twenty one thousand'
7
+ WeightedDigitGroup.new(%w[2 1], 1).to_s.should == 'twenty one thousand'
8
8
  end
9
9
  it "should should convert 123 thousand" do
10
- WeightedDigitGroup.new(%w[1 2 3], 1).to_w.should == 'one hundred and twenty three thousand'
10
+ WeightedDigitGroup.new(%w[1 2 3], 1).to_s.should == 'one hundred and twenty three thousand'
11
11
  end
12
12
  it "should should convert 103 million" do
13
- WeightedDigitGroup.new(%w[1 0 3], 2).to_w.should == 'one hundred and three million'
13
+ WeightedDigitGroup.new(%w[1 0 3], 2).to_s.should == 'one hundred and three million'
14
14
  end
15
15
  it "should should convert 000 thousand to empty string" do
16
- WeightedDigitGroup.new(%w[0 0 0], 1).to_w.should == ''
16
+ WeightedDigitGroup.new(%w[0 0 0], 1).to_s.should == ''
17
17
  end
18
18
  it "should should convert 000 million to empty string" do
19
- WeightedDigitGroup.new(%w[0 0 0], 2).to_w.should == ''
19
+ WeightedDigitGroup.new(%w[0 0 0], 2).to_s.should == ''
20
20
  end
21
21
  end
22
22
  end
23
23
  end
24
-
@@ -1,12 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- module Wintr
4
- describe WordArray do
5
- describe "#to_w" do
6
- it "should join it's array then strip and squeeze spaces" do
7
- WordArray.new([' foo ', ' bar ']).to_w.should == 'foo bar'
8
- end
3
+ describe Wintr::WordArray do
4
+ describe "#to_s" do
5
+ it "joins it's array then squeezes spaces" do
6
+ Wintr::WordArray.new([' foo ', ' bar ']).to_s.should == 'foo bar'
9
7
  end
10
8
  end
11
9
  end
12
-
metadata CHANGED
@@ -1,29 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wintr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - R Headley
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-02-26 00:00:00.000000000 Z
11
+ date: 2015-02-23 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
- requirement: &13343580 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '2.8'
22
20
  type: :development
23
21
  prerelease: false
24
- version_requirements: *13343580
25
- description: A Ruby number to word converter (handles integers up to a maximum of
26
- 999 duotrigintillion!)
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.8'
27
+ description: Convert integers into their word equivalents
27
28
  email:
28
29
  - headleyra@yahoo.com
29
30
  executables: []
@@ -31,58 +32,57 @@ extensions: []
31
32
  extra_rdoc_files:
32
33
  - README.md
33
34
  files:
34
- - lib/wintr/weighted_digit_group.rb
35
- - lib/wintr/number.rb
35
+ - README.md
36
+ - lib/wintr.rb
36
37
  - lib/wintr/digit_group.rb
38
+ - lib/wintr/number.rb
39
+ - lib/wintr/one_digit_group.rb
37
40
  - lib/wintr/power_of_thousand.rb
38
- - lib/wintr/word_array.rb
41
+ - lib/wintr/three_digit_group.rb
39
42
  - lib/wintr/two_digit_group.rb
40
43
  - lib/wintr/version.rb
41
- - lib/wintr/three_digit_group.rb
42
- - lib/wintr/one_digit_group.rb
43
- - lib/wintr.rb
44
- - README.md
45
- - spec/wintr/power_of_thousand_spec.rb
46
- - spec/wintr/word_array_spec.rb
47
- - spec/wintr/weighted_digit_group_spec.rb
48
- - spec/wintr/one_digit_group_spec.rb
44
+ - lib/wintr/weighted_digit_group.rb
45
+ - lib/wintr/word_array.rb
46
+ - spec/spec_helper.rb
47
+ - spec/wintr/digit_group_spec.rb
49
48
  - spec/wintr/number_spec.rb
50
- - spec/wintr/two_digit_group_spec.rb
49
+ - spec/wintr/one_digit_group_spec.rb
50
+ - spec/wintr/power_of_thousand_spec.rb
51
51
  - spec/wintr/three_digit_group_spec.rb
52
- - spec/wintr/digit_group_spec.rb
53
- - spec/spec_helper.rb
52
+ - spec/wintr/two_digit_group_spec.rb
53
+ - spec/wintr/weighted_digit_group_spec.rb
54
+ - spec/wintr/word_array_spec.rb
54
55
  homepage: http://github.com/headleyra/wintr
55
56
  licenses:
56
57
  - MIT
58
+ metadata: {}
57
59
  post_install_message:
58
60
  rdoc_options: []
59
61
  require_paths:
60
62
  - lib
61
63
  required_ruby_version: !ruby/object:Gem::Requirement
62
- none: false
63
64
  requirements:
64
- - - ! '>='
65
+ - - ">="
65
66
  - !ruby/object:Gem::Version
66
67
  version: '0'
67
68
  required_rubygems_version: !ruby/object:Gem::Requirement
68
- none: false
69
69
  requirements:
70
- - - ! '>='
70
+ - - ">="
71
71
  - !ruby/object:Gem::Version
72
72
  version: '0'
73
73
  requirements: []
74
74
  rubyforge_project:
75
- rubygems_version: 1.8.15
75
+ rubygems_version: 2.4.5
76
76
  signing_key:
77
- specification_version: 3
78
- summary: A Ruby number to word converter
77
+ specification_version: 4
78
+ summary: A Ruby integer to word converter
79
79
  test_files:
80
+ - spec/wintr/two_digit_group_spec.rb
81
+ - spec/wintr/number_spec.rb
82
+ - spec/wintr/digit_group_spec.rb
83
+ - spec/wintr/one_digit_group_spec.rb
84
+ - spec/wintr/three_digit_group_spec.rb
80
85
  - spec/wintr/power_of_thousand_spec.rb
81
86
  - spec/wintr/word_array_spec.rb
82
87
  - spec/wintr/weighted_digit_group_spec.rb
83
- - spec/wintr/one_digit_group_spec.rb
84
- - spec/wintr/number_spec.rb
85
- - spec/wintr/two_digit_group_spec.rb
86
- - spec/wintr/three_digit_group_spec.rb
87
- - spec/wintr/digit_group_spec.rb
88
88
  - spec/spec_helper.rb