wintr 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +11 -1
- data/lib/wintr/power_of_thousand.rb +32 -1
- data/lib/wintr/version.rb +1 -1
- data/spec/wintr/number_spec.rb +95 -0
- data/spec/wintr/power_of_thousand_spec.rb +0 -3
- metadata +5 -4
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Wintr
|
2
2
|
|
3
|
-
A number to word converter.
|
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
|
+
|
5
|
+
## Install
|
6
|
+
|
7
|
+
gem install wintr
|
4
8
|
|
5
9
|
## Usage
|
6
10
|
|
@@ -12,3 +16,9 @@ A number to word converter.
|
|
12
16
|
|
13
17
|
Wintr::Number.new(951_213_724).to_w
|
14
18
|
# => "nine hundred and fifty one million two hundred and thirteen thousand seven hundred and twenty four"
|
19
|
+
|
20
|
+
## Licence
|
21
|
+
|
22
|
+
Released under the MIT License. See the [LICENCE.md](https://github.com/headleyra/wintr/blob/master/LICENCE.md) file for further details.
|
23
|
+
|
24
|
+
|
@@ -2,7 +2,38 @@ module Wintr
|
|
2
2
|
class PowerOfThousand
|
3
3
|
POWER = {
|
4
4
|
1 => 'thousand',
|
5
|
-
2 => 'million'
|
5
|
+
2 => 'million',
|
6
|
+
3 => 'billion',
|
7
|
+
4 => 'trillion',
|
8
|
+
5 => 'quadrillion',
|
9
|
+
6 => 'quintillion',
|
10
|
+
7 => 'sextillion',
|
11
|
+
8 => 'septillion',
|
12
|
+
9 => 'octillion',
|
13
|
+
10 => 'nonillion',
|
14
|
+
11 => 'decillion',
|
15
|
+
12 => 'undecillion',
|
16
|
+
13 => 'duodecillion',
|
17
|
+
14 => 'tredecillion',
|
18
|
+
15 => 'quattuordecillion',
|
19
|
+
16 => 'quindecillion',
|
20
|
+
17 => 'sexdecillion',
|
21
|
+
18 => 'septendecillion',
|
22
|
+
19 => 'octodecillion',
|
23
|
+
20 => 'novemdecillion',
|
24
|
+
21 => 'vigintillion',
|
25
|
+
22 => 'unvigintillion',
|
26
|
+
23 => 'duovigintillion',
|
27
|
+
24 => 'trevigintillion',
|
28
|
+
25 => 'quattuorvigintillion',
|
29
|
+
26 => 'quinvigintillion',
|
30
|
+
27 => 'sexvigintillion',
|
31
|
+
28 => 'septenvigintillion',
|
32
|
+
29 => 'octovigintillion',
|
33
|
+
30 => 'novemvigintillion',
|
34
|
+
31 => 'trigintillion',
|
35
|
+
32 => 'untrigintillion',
|
36
|
+
33 => 'duotrigintillion'
|
6
37
|
}
|
7
38
|
|
8
39
|
def initialize(power)
|
data/lib/wintr/version.rb
CHANGED
data/spec/wintr/number_spec.rb
CHANGED
@@ -81,6 +81,101 @@ module Wintr
|
|
81
81
|
it "should convert 3,007" do
|
82
82
|
Number.new(3007).to_w.should == 'three thousand and seven'
|
83
83
|
end
|
84
|
+
|
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'
|
178
|
+
end
|
84
179
|
end
|
85
180
|
end
|
86
181
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wintr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-02-26 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &14195540 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '2.8'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *14195540
|
25
25
|
description: A number to word converter
|
26
26
|
email:
|
27
27
|
- headleyra@yahoo.com
|
@@ -51,7 +51,8 @@ files:
|
|
51
51
|
- spec/wintr/digit_group_spec.rb
|
52
52
|
- spec/spec_helper.rb
|
53
53
|
homepage: http://github.com/headleyra/wintr
|
54
|
-
licenses:
|
54
|
+
licenses:
|
55
|
+
- MIT
|
55
56
|
post_install_message:
|
56
57
|
rdoc_options: []
|
57
58
|
require_paths:
|