numbers_in_words 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest ADDED
@@ -0,0 +1,11 @@
1
+ Manifest
2
+ Rakefile
3
+ examples/display_numbers_in_words.rb
4
+ index_cyclo.html
5
+ lib/numbers_in_words.rb
6
+ lib/numbers_in_words.rb_cyclo.html
7
+ lib/words_in_numbers.rb
8
+ lib/words_in_numbers.rb_cyclo.html
9
+ numbers_in_words.rb
10
+ spec/numbers_in_words_spec.rb
11
+ spec/words_in_numbers_spec.rb
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+ Echoe.new('numbers_in_words','0.0.7') do |e|
5
+ e.description = ""
6
+ e.url = "http://rubygems.org/gems/numbers_in_words"
7
+ e.author = "Mark Burns"
8
+ e.email = "markthedeveloper@googlemail.com"
9
+ e.ignore_pattern = ["tmp/*",".git/*"]
10
+ e.development_dependencies = ['active_support']
11
+ end
12
+
13
+
data/index_cyclo.html ADDED
@@ -0,0 +1,83 @@
1
+ <html><head><title>Index for cyclomatic complexity</title></head>
2
+ <style>
3
+ body {
4
+ margin: 20px;
5
+ padding: 0;
6
+ font-size: 12px;
7
+ font-family: bitstream vera sans, verdana, arial, sans serif;
8
+ background-color: #efefef;
9
+ }
10
+
11
+ table {
12
+ border-collapse: collapse;
13
+ /*border-spacing: 0;*/
14
+ border: 1px solid #666;
15
+ background-color: #fff;
16
+ margin-bottom: 20px;
17
+ }
18
+
19
+ table, th, th+th, td, td+td {
20
+ border: 1px solid #ccc;
21
+ }
22
+
23
+ table th {
24
+ font-size: 12px;
25
+ color: #fc0;
26
+ padding: 4px 0;
27
+ background-color: #336;
28
+ }
29
+
30
+ th, td {
31
+ padding: 4px 10px;
32
+ }
33
+
34
+ td {
35
+ font-size: 13px;
36
+ }
37
+
38
+ .class_name {
39
+ font-size: 17px;
40
+ margin: 20px 0 0;
41
+ }
42
+
43
+ .class_complexity {
44
+ margin: 0 auto;
45
+ }
46
+
47
+ .class_complexity>.class_complexity {
48
+ margin: 0;
49
+ }
50
+
51
+ .class_total_complexity, .class_total_lines, .start_token_count, .file_count {
52
+ font-size: 13px;
53
+ font-weight: bold;
54
+ }
55
+
56
+ .class_total_complexity, .class_total_lines {
57
+ color: #c00;
58
+ }
59
+
60
+ .start_token_count, .file_count {
61
+ color: #333;
62
+ }
63
+
64
+ .warning {
65
+ background-color: yellow;
66
+ }
67
+
68
+ .error {
69
+ background-color: #f00;
70
+ }
71
+ </style>
72
+
73
+ <body>
74
+ <h1>Index for cyclomatic complexity</h1>
75
+
76
+ <hr/>
77
+ <h2 class="class_name">Analyzed Files</h2>
78
+ <ul>
79
+ <li>
80
+ <p class="file_name"><a href="./lib/words_in_numbers.rb_cyclo.html">lib/words_in_numbers.rb</a>
81
+ </li>
82
+ </ul>
83
+ </body></html>
@@ -0,0 +1,100 @@
1
+ <html><head><title>Cyclometric Complexity</title></head>
2
+ <style>
3
+ body {
4
+ margin: 20px;
5
+ padding: 0;
6
+ font-size: 12px;
7
+ font-family: bitstream vera sans, verdana, arial, sans serif;
8
+ background-color: #efefef;
9
+ }
10
+
11
+ table {
12
+ border-collapse: collapse;
13
+ /*border-spacing: 0;*/
14
+ border: 1px solid #666;
15
+ background-color: #fff;
16
+ margin-bottom: 20px;
17
+ }
18
+
19
+ table, th, th+th, td, td+td {
20
+ border: 1px solid #ccc;
21
+ }
22
+
23
+ table th {
24
+ font-size: 12px;
25
+ color: #fc0;
26
+ padding: 4px 0;
27
+ background-color: #336;
28
+ }
29
+
30
+ th, td {
31
+ padding: 4px 10px;
32
+ }
33
+
34
+ td {
35
+ font-size: 13px;
36
+ }
37
+
38
+ .class_name {
39
+ font-size: 17px;
40
+ margin: 20px 0 0;
41
+ }
42
+
43
+ .class_complexity {
44
+ margin: 0 auto;
45
+ }
46
+
47
+ .class_complexity>.class_complexity {
48
+ margin: 0;
49
+ }
50
+
51
+ .class_total_complexity, .class_total_lines, .start_token_count, .file_count {
52
+ font-size: 13px;
53
+ font-weight: bold;
54
+ }
55
+
56
+ .class_total_complexity, .class_total_lines {
57
+ color: #c00;
58
+ }
59
+
60
+ .start_token_count, .file_count {
61
+ color: #333;
62
+ }
63
+
64
+ .warning {
65
+ background-color: yellow;
66
+ }
67
+
68
+ .error {
69
+ background-color: #f00;
70
+ }
71
+ </style>
72
+ <body>
73
+ <div class="class_complexity">
74
+ <h2 class="class_name">Module : NumbersInWords</h2>
75
+ <div class="class_total_complexity">Total Complexity: 36</div>
76
+ <div class="class_total_lines">Total Lines: 197</div>
77
+ <table width="100%" border="1">
78
+ <tr><th>Method</th><th>Complexity</th><th># Lines</th></tr>
79
+ <tr><td>english_group</td><td>5</td><td>13</td></tr>
80
+ <tr><td>in_english</td><td class="warning">10</td><td>31</td></tr>
81
+ </table>
82
+ </div>
83
+ <div class="class_complexity">
84
+ <h2 class="class_name">Class : Fixnum</h2>
85
+ <div class="class_total_complexity">Total Complexity: 0</div>
86
+ <div class="class_total_lines">Total Lines: 2</div>
87
+ <table width="100%" border="1">
88
+ <tr><th>Method</th><th>Complexity</th><th># Lines</th></tr>
89
+ </table>
90
+ </div>
91
+ <div class="class_complexity">
92
+ <h2 class="class_name">Class : Bignum</h2>
93
+ <div class="class_total_complexity">Total Complexity: 0</div>
94
+ <div class="class_total_lines">Total Lines: 2</div>
95
+ <table width="100%" border="1">
96
+ <tr><th>Method</th><th>Complexity</th><th># Lines</th></tr>
97
+ </table>
98
+ </div>
99
+ </body>
100
+ </html>
@@ -0,0 +1,199 @@
1
+ module WordsInNumbers
2
+
3
+ DIGITS= %w[zero one two three four five six seven eight nine]
4
+
5
+ EXCEPTIONS = {
6
+ "ten"=>10,
7
+ "eleven"=>11,
8
+ "twelve"=>12,
9
+ "thirteen"=>13,
10
+ "fourteen"=>14,
11
+ "fifteen"=>15,
12
+ "sixteen"=>16,
13
+ "seventeen"=>17,
14
+ "eighteen"=>18,
15
+ "nineteen"=>19,
16
+ "twenty"=>20,
17
+ "thirty"=>30,
18
+ "forty"=>40,
19
+ "fifty"=>50,
20
+ "sixty"=>60,
21
+ "seventy"=>70,
22
+ "eighty"=>80,
23
+ "ninety"=>90
24
+ }
25
+
26
+
27
+ POWERS_OF_TEN ={
28
+ "one"=>0,
29
+ "ten"=> 1 ,
30
+ "hundred"=> 2,
31
+ "thousand"=> 3 ,
32
+ "million"=> 6,
33
+ "billion"=> 9,
34
+ "trillion"=> 12,
35
+ "quadrillion"=> 15,
36
+ "quintillion"=> 18,
37
+ "sextillion"=> 21,
38
+ "septillion"=> 24,
39
+ "octillion"=> 27,
40
+ "nonillion"=> 30,
41
+ "decillion"=> 33,
42
+ "undecillion"=> 36,
43
+ "duodecillion"=> 39,
44
+ "tredecillion"=> 42,
45
+ "quattuordecillion"=> 45,
46
+ "quindecillion"=> 48,
47
+ "sexdecillion"=> 51,
48
+ "septendecillion"=> 54,
49
+ "octodecillion"=> 57,
50
+ "novemdecillion"=> 60,
51
+ "vigintillion"=> 63,
52
+ "unvigintillion"=> 66,
53
+ "duovigintillion"=> 69,
54
+ "trevigintillion"=> 72,
55
+ "quattuorvigintillion"=> 75,
56
+ "quinvigintillion"=> 78,
57
+ "sexvigintillion"=> 81,
58
+ "septenvigintillion"=> 84,
59
+ "octovigintillion"=> 87,
60
+ "novemvigintillion"=> 90,
61
+ "trigintillion"=> 93,
62
+ "untrigintillion"=> 96,
63
+ "duotrigintillion"=> 99,
64
+ "googol"=> 100
65
+ }
66
+
67
+ def in_numbers
68
+ #easy single word case
69
+ text = self.to_s
70
+ text.downcase!
71
+ text.gsub! /[^a-z ]/, " "
72
+ to_remove = true
73
+ until to_remove.nil?
74
+ to_remove=text.gsub! " ", " " until to_remove.nil?
75
+ end
76
+
77
+ if text =~ /^minus /
78
+ return -1 * (text.gsub(/^minus /, "")).in_numbers
79
+ end
80
+ word = word_to_integer(text)
81
+ return word unless word.nil?
82
+ words = text.split " "
83
+ integers = word_array_to_integers words
84
+
85
+ i= parse_numbers(integers)
86
+ return i unless i.nil?
87
+ return nil
88
+ end
89
+
90
+
91
+ # Example: 364,895,457,898
92
+ #three hundred and sixty four billion eight hundred and ninety five million
93
+ #four hundred and fifty seven thousand eight hundred and ninety eight
94
+ #
95
+ #3 100 60 4 10^9, 8 100 90 5 10^6, 4 100 50 7 1000, 8 100 90 8
96
+ # memory answer
97
+ #x1. 3 add to memory because answer and memory are zero 3 0
98
+ #x2. memory * 100 (because memory<100) 300 0
99
+ #x3. 60 add to memory because memory > 60 360 0
100
+ #x3. 4 add to memory because memory > 4 364 0
101
+ #x4. multiply memory by 10^9 because memory < power of ten 364*10^9 0
102
+ #x5. add memory to answer (and reset)memory > 8 (memory pow of ten > 2) 0 364*10^9
103
+ #x6. 8 add to memory because not finished 8 ''
104
+ #x7. multiply memory by 100 because memory < 100 800 ''
105
+ #x8. add 90 to memory because memory > 90 890 ''
106
+ #x9. add 5 to memory because memory > 5 895 ''
107
+ #x10. multiply memory by 10^6 because memory < power of ten 895*10^6 ''
108
+ #x11. add memory to answer (and reset) because memory power ten > 2 0 364895 * 10^6
109
+ #x12. 4 add to memory because not finished 4 ''
110
+ #x13. memory * 100 because memory < 100 400 ''
111
+ #x14. memory + 50 because memory > 50 450 ''
112
+ #x15. memory + 7 because memory > 7 457 ''
113
+ #x16. memory * 1000 because memory < 1000 457000 ''
114
+ #x17. add memory to answer (and reset)memory > 8 (memory pow of ten > 2) 0 364895457000
115
+ #x18. 8 add to memory because not finished 8 ''
116
+ #x19. memory * 100 because memory < 100 800 ''
117
+ #x14. memory + 90 because memory > 90 890 ''
118
+ #x15. memory + 8 because memory > 8 898 ''
119
+ #16. finished so add memory to answer
120
+
121
+ #Example
122
+ #2001
123
+ #two thousand and one
124
+ #2 1000 1
125
+ # memory answer
126
+ #1. add 2 to memory because first 2 0
127
+ #2. multiply memory by 1000 because memory < 1000 2000 0
128
+ #3. add memory to answer,reset, because power of ten>2 0 2000
129
+ #4. add 1 to memory 1 2000
130
+ #5. finish - add memory to answer 0 2001
131
+ def parse_numbers(integers)
132
+ memory = 0
133
+ answer = 0
134
+ reset = true #reset each time memory is reset
135
+ integers.each_with_index do |i, index|
136
+ if reset
137
+ reset = false
138
+ memory += i
139
+ else
140
+ #x4. multiply memory by 10^9 because memory < power of ten
141
+ if is_power_of_ten?(i)
142
+ if power_of_ten(i)> 2
143
+ memory *= i
144
+ #17. add memory to answer (and reset) (memory pow of ten > 2)
145
+ answer += memory
146
+ memory = 0
147
+ reset = true
148
+ end
149
+ end
150
+
151
+ if memory < i
152
+ memory *= i
153
+ else
154
+ memory += i
155
+ end
156
+ end
157
+ end
158
+ answer += memory
159
+ end
160
+
161
+ def power_of_ten integer
162
+ Math.log10(integer)
163
+ end
164
+
165
+ def is_power_of_ten? integer
166
+ power_of_ten(integer)==power_of_ten(integer).to_i
167
+ end
168
+
169
+ #handles simple single word numbers
170
+ #e.g. one, seven, twenty, eight, thousand etc
171
+ def word_to_integer word
172
+ text = word.to_s.chomp.strip
173
+ #digits 0-9
174
+ digit = DIGITS.index(text)
175
+ return digit unless digit.nil?
176
+
177
+ #digits which are exceptions
178
+ exception = EXCEPTIONS[text]
179
+ return exception unless exception.nil?
180
+
181
+ power = POWERS_OF_TEN[text]
182
+ return 10**power unless power.nil?
183
+ return nil
184
+ end
185
+
186
+ def word_array_to_integers words
187
+ out = []
188
+ words.map do |i|
189
+ word = word_to_integer(i)
190
+ out << word unless word.nil?
191
+ end
192
+ return out
193
+ end
194
+ end
195
+
196
+ class String
197
+ include WordsInNumbers
198
+ end
199
+
@@ -0,0 +1,92 @@
1
+ <html><head><title>Cyclometric Complexity</title></head>
2
+ <style>
3
+ body {
4
+ margin: 20px;
5
+ padding: 0;
6
+ font-size: 12px;
7
+ font-family: bitstream vera sans, verdana, arial, sans serif;
8
+ background-color: #efefef;
9
+ }
10
+
11
+ table {
12
+ border-collapse: collapse;
13
+ /*border-spacing: 0;*/
14
+ border: 1px solid #666;
15
+ background-color: #fff;
16
+ margin-bottom: 20px;
17
+ }
18
+
19
+ table, th, th+th, td, td+td {
20
+ border: 1px solid #ccc;
21
+ }
22
+
23
+ table th {
24
+ font-size: 12px;
25
+ color: #fc0;
26
+ padding: 4px 0;
27
+ background-color: #336;
28
+ }
29
+
30
+ th, td {
31
+ padding: 4px 10px;
32
+ }
33
+
34
+ td {
35
+ font-size: 13px;
36
+ }
37
+
38
+ .class_name {
39
+ font-size: 17px;
40
+ margin: 20px 0 0;
41
+ }
42
+
43
+ .class_complexity {
44
+ margin: 0 auto;
45
+ }
46
+
47
+ .class_complexity>.class_complexity {
48
+ margin: 0;
49
+ }
50
+
51
+ .class_total_complexity, .class_total_lines, .start_token_count, .file_count {
52
+ font-size: 13px;
53
+ font-weight: bold;
54
+ }
55
+
56
+ .class_total_complexity, .class_total_lines {
57
+ color: #c00;
58
+ }
59
+
60
+ .start_token_count, .file_count {
61
+ color: #333;
62
+ }
63
+
64
+ .warning {
65
+ background-color: yellow;
66
+ }
67
+
68
+ .error {
69
+ background-color: #f00;
70
+ }
71
+ </style>
72
+ <body>
73
+ <div class="class_complexity">
74
+ <h2 class="class_name">Module : WordsInNumbers</h2>
75
+ <div class="class_total_complexity">Total Complexity: 21</div>
76
+ <div class="class_total_lines">Total Lines: 194</div>
77
+ <table width="100%" border="1">
78
+ <tr><th>Method</th><th>Complexity</th><th># Lines</th></tr>
79
+ <tr><td>in_numbers</td><td>6</td><td>22</td></tr>
80
+ <tr><td>parse_numbers</td><td>6</td><td>28</td></tr>
81
+ </table>
82
+ </div>
83
+ <div class="class_complexity">
84
+ <h2 class="class_name">Class : String</h2>
85
+ <div class="class_total_complexity">Total Complexity: 0</div>
86
+ <div class="class_total_lines">Total Lines: 2</div>
87
+ <table width="100%" border="1">
88
+ <tr><th>Method</th><th>Complexity</th><th># Lines</th></tr>
89
+ </table>
90
+ </div>
91
+ </body>
92
+ </html>
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{numbers_in_words}
5
+ s.version = "0.0.7"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Mark Burns"]
9
+ s.date = %q{2010-04-06}
10
+ s.description = %q{}
11
+ s.email = %q{markthedeveloper@googlemail.com}
12
+ s.extra_rdoc_files = ["lib/numbers_in_words.rb", "lib/numbers_in_words.rb_cyclo.html", "lib/words_in_numbers.rb", "lib/words_in_numbers.rb_cyclo.html"]
13
+ s.files = ["Manifest", "Rakefile", "examples/display_numbers_in_words.rb", "index_cyclo.html", "lib/numbers_in_words.rb", "lib/numbers_in_words.rb_cyclo.html", "lib/words_in_numbers.rb", "lib/words_in_numbers.rb_cyclo.html", "numbers_in_words.rb", "spec/numbers_in_words_spec.rb", "spec/words_in_numbers_spec.rb", "numbers_in_words.gemspec"]
14
+ s.homepage = %q{http://rubygems.org/gems/numbers_in_words}
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Numbers_in_words"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{numbers_in_words}
18
+ s.rubygems_version = %q{1.3.6}
19
+ s.summary = %q{}
20
+
21
+ if s.respond_to? :specification_version then
22
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
+ s.specification_version = 3
24
+
25
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
26
+ s.add_development_dependency(%q<active_support>, [">= 0"])
27
+ else
28
+ s.add_dependency(%q<active_support>, [">= 0"])
29
+ end
30
+ else
31
+ s.add_dependency(%q<active_support>, [">= 0"])
32
+ end
33
+ end
@@ -0,0 +1,8 @@
1
+ require 'rubygems'
2
+
3
+ $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), 'lib'))
4
+
5
+ require 'lib/numbers_in_words'
6
+ require 'lib/words_in_numbers'
7
+
8
+
@@ -38,6 +38,7 @@ describe Fixnum do
38
38
  -123456789.in_words.should == "minus one hundred and twenty three million four hundred and fifty six thousand seven hundred and eighty nine"
39
39
  end
40
40
  it "should handle decimals" do
41
+ pending
41
42
  1.1.in_words.should == "one point one"
42
43
  1.2345678.in_words.should == "one point two three four five six seven eight"
43
44
  1000.2345678.in_words.should == "one thousand point two three four five six seven eight"
@@ -0,0 +1,94 @@
1
+ require 'lib/words_in_numbers'
2
+ describe WordsInNumbers do
3
+ it "should do the digits 0-10" do
4
+ "zero".in_numbers.should == 0
5
+ "one".in_numbers.should == 1
6
+ "two".in_numbers.should == 2
7
+ "three".in_numbers.should == 3
8
+ "four".in_numbers.should == 4
9
+ "five".in_numbers.should == 5
10
+ "six".in_numbers.should == 6
11
+ "seven".in_numbers.should == 7
12
+ "eight".in_numbers.should == 8
13
+ "nine".in_numbers.should == 9
14
+ end
15
+ it "should handle numbers for which there is one word" do
16
+ "ten".in_numbers.should == 10
17
+ "eleven".in_numbers.should == 11
18
+ "twelve".in_numbers.should == 12
19
+ "thirteen".in_numbers.should == 13
20
+ "fourteen".in_numbers.should == 14
21
+ "fifteen".in_numbers.should == 15
22
+ "sixteen".in_numbers.should == 16
23
+ "seventeen".in_numbers.should == 17
24
+ "eighteen".in_numbers.should == 18
25
+ "nineteen".in_numbers.should == 19
26
+ "twenty".in_numbers.should == 20
27
+ end
28
+ it "should handle two word numbers up to 100" do
29
+ "twenty one".in_numbers.should == 21
30
+ "twenty two".in_numbers.should == 22
31
+ "twenty three".in_numbers.should == 23
32
+ "twenty four".in_numbers.should == 24
33
+ "twenty five".in_numbers.should == 25
34
+ "twenty six".in_numbers.should == 26
35
+ "twenty seven".in_numbers.should == 27
36
+ "twenty eight".in_numbers.should == 28
37
+ "seventy six".in_numbers.should == 76
38
+ "ninety nine".in_numbers.should == 99
39
+ end
40
+ it "should handle hundreds" do
41
+ "one hundred".in_numbers.should == 100
42
+ "two hundred".in_numbers.should == 200
43
+ "three hundred".in_numbers.should == 300
44
+ "nine hundred".in_numbers.should == 900
45
+ "one hundred and seventy six".in_numbers.should == 176
46
+ "one hundred and seventy nine".in_numbers.should == 179
47
+ "nine hundred and ninety nine".in_numbers.should == 999
48
+
49
+ end
50
+ it "should handle unusual hundreds" do
51
+ "eleven hundred".in_numbers.should == 1100
52
+ "twelve hundred".in_numbers.should == 1200
53
+ "thirteen hundred".in_numbers.should == 1300
54
+ "fifteen hundred".in_numbers.should == 1500
55
+ "nineteen hundred".in_numbers.should == 1900
56
+
57
+ end
58
+ it "should handle thousands" do
59
+ "two thousand and one".in_numbers.should == 2001
60
+ "one thousand".in_numbers.should == 1000
61
+ "two thousand".in_numbers.should == 2000
62
+ "three thousand".in_numbers.should == 3000
63
+ "nine thousand".in_numbers.should == 9000
64
+ "nine thousand two hundred".in_numbers.should == 9200
65
+ "nine thousand two hundred and seven".in_numbers.should == 9207
66
+ "nine thousand two hundred and ninety seven".in_numbers.should == 9297
67
+ end
68
+
69
+ it "should handle larger numbers" do
70
+ "one million".in_numbers.should == 1000000
71
+ "two googol five billion and seventy six".in_numbers.should == (2*10**100 + 5*10**9 + 76)
72
+ "thirty seven million".in_numbers.should == 37 * 10**6
73
+ "twenty six googol".in_numbers.should == 26 * 10**100
74
+ end
75
+
76
+ it "should handle numbers in hundreds of thousands etc" do
77
+ "nine hundred thousand".in_numbers.should == 900000
78
+ "three hundred and fifty seven thousand".in_numbers.should == 357000
79
+ "five million three hundred and fifty seven thousand".in_numbers.should == 5357000
80
+ "nine hundred and ninety nine trillion".in_numbers.should == 999 * 10**12
81
+ end
82
+ it "should handle negative numbers" do
83
+ "minus one".in_numbers.should == -1
84
+ "minus two googol".in_numbers.should == -2 * 10**100
85
+ "minus nine hundred and ninety nine trillion".in_numbers.should == -999 * 10**12
86
+ end
87
+
88
+ it "should ignore punctuation and capitalisation" do
89
+ "Minus one".in_numbers.should == -1
90
+ "FIVE Million, three hundred and fifty-seVen Thousand".in_numbers.should == 5357000
91
+ "FIVE,,./';';';[] Million, three hundred and fifty-seVen Thousand".in_numbers.should == 5357000
92
+
93
+ end
94
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 6
9
- version: 0.0.6
8
+ - 7
9
+ version: 0.0.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Mark Burns
@@ -16,28 +16,53 @@ cert_chain: []
16
16
 
17
17
  date: 2010-04-06 00:00:00 +01:00
18
18
  default_executable:
19
- dependencies: []
20
-
21
- description: "Use the #in_words method on a positive or negative Fixnum or Bignum to try it out. or String#in_numbers to get a Fixnum or Bignum"
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: active_support
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :development
31
+ version_requirements: *id001
32
+ description: ""
22
33
  email: markthedeveloper@googlemail.com
23
34
  executables: []
24
35
 
25
36
  extensions: []
26
37
 
27
- extra_rdoc_files: []
28
-
29
- files:
30
- - README
38
+ extra_rdoc_files:
31
39
  - lib/numbers_in_words.rb
40
+ - lib/numbers_in_words.rb_cyclo.html
41
+ - lib/words_in_numbers.rb
42
+ - lib/words_in_numbers.rb_cyclo.html
43
+ files:
44
+ - Manifest
45
+ - Rakefile
32
46
  - examples/display_numbers_in_words.rb
47
+ - index_cyclo.html
48
+ - lib/numbers_in_words.rb
49
+ - lib/numbers_in_words.rb_cyclo.html
50
+ - lib/words_in_numbers.rb
51
+ - lib/words_in_numbers.rb_cyclo.html
52
+ - numbers_in_words.rb
33
53
  - spec/numbers_in_words_spec.rb
54
+ - spec/words_in_numbers_spec.rb
55
+ - numbers_in_words.gemspec
34
56
  has_rdoc: true
35
- homepage: http://github.com/markburns/numbers_in_words
57
+ homepage: http://rubygems.org/gems/numbers_in_words
36
58
  licenses: []
37
59
 
38
60
  post_install_message:
39
- rdoc_options: []
40
-
61
+ rdoc_options:
62
+ - --line-numbers
63
+ - --inline-source
64
+ - --title
65
+ - Numbers_in_words
41
66
  require_paths:
42
67
  - lib
43
68
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -52,14 +77,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
77
  - - ">="
53
78
  - !ruby/object:Gem::Version
54
79
  segments:
55
- - 0
56
- version: "0"
80
+ - 1
81
+ - 2
82
+ version: "1.2"
57
83
  requirements: []
58
84
 
59
85
  rubyforge_project: numbers_in_words
60
86
  rubygems_version: 1.3.6
61
87
  signing_key:
62
88
  specification_version: 3
63
- summary: Turns integers into their long-hand text form like "two thousand and one", and vice-versa for strings to integers
89
+ summary: ""
64
90
  test_files: []
65
91
 
data/README DELETED
@@ -1,70 +0,0 @@
1
- Installation
2
- ============
3
-
4
-
5
- gem install numbers_in_words
6
-
7
- or
8
-
9
- sudo gem install numbers_in_words
10
-
11
-
12
-
13
- The file numbers_to_words defines a module NumbersToWords which is included in Fixnum and Bignum.
14
- The in_words method can then be used on any Fixnum or Bignum object.
15
-
16
- E.g.
17
- >require 'numbers_in_words'
18
- >112.in_words
19
- #=> one hundred and twelve
20
-
21
- To try it out the program display_numbers_to_words.rb expects two integer parameters to define a
22
- range. It then prints out all numbers in words included in this range.
23
-
24
- e.g.
25
-
26
- >ruby display_numbers_to_words.rb 1 11
27
- one
28
- two
29
- three
30
- four
31
- five
32
- six
33
- seven
34
- eight
35
- nine
36
- ten
37
- eleven
38
-
39
- Whilst creating this project I realized that in English:
40
-
41
- * Numbers are grouped in groups of threes
42
- * Numbers less than 1,000 are grouped by hundreds and then by tens
43
- * There are specific rules for when we put an "and" in between numbers
44
-
45
- It makes sense to manage the numbers by these groups, so
46
- I created a method groups_of which will split any integer into
47
- groups of a certain size. It returns a hash with the power of ten
48
- as the key and the multiplier as the value. E.g:
49
-
50
- > 31245.groups_of(3)
51
- #=>
52
- {0=>245,3=>31} #i.e. 31 thousands, and 245 ones
53
-
54
- > 245.group_of(2)
55
- #=>
56
- {0=>45,2=>2} #i.e. 2 hundreds, and 45 ones
57
-
58
- I also created a method group_words takes a block and a size parameter
59
- This method which could be used by different languages.
60
- (In Japanese numbers are grouped in groups of 4, so it makes sense to try and
61
- separate the language related stuff from the number grouping related stuff)
62
-
63
- Example of usage:
64
- 245.group_words(2,"English") do |power, name, digits|
65
- puts "#{digits}*10^#{power} #{digits} #{name}s"
66
- end
67
-
68
- 2*10^2= 2 hundreds
69
- 45*10^0 = 45 ones
70
-