numerouno 0.0.1 → 0.1.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.
data/History.txt CHANGED
@@ -3,3 +3,9 @@
3
3
  * 1 major enhancement:
4
4
  * Initial release
5
5
  * mmmm...has that new gem smell
6
+
7
+
8
+ == 0.1.0 2009-06-17
9
+
10
+ * 1 minor enhancement:
11
+ * Supports literal number strings like '7'
data/README.rdoc CHANGED
@@ -1,6 +1,7 @@
1
1
  = Numerouno
2
2
 
3
3
  * http://github.com/brentsnook/numerouno
4
+ * http://groups.google.com/group/numerouno-number-parsing
4
5
 
5
6
  English natural language parser for numbers.
6
7
 
@@ -12,8 +13,6 @@ Recognises numbers in the trillions.
12
13
 
13
14
  == Installation
14
15
 
15
- Whoah, hang on there. Not up on Rubyforge yet but hopefully soon. When it is:
16
-
17
16
  sudo gem install numerouno
18
17
 
19
18
  === Building the Gem yourself
@@ -5,13 +5,22 @@ module Numerouno
5
5
  extend SearchMethods
6
6
 
7
7
  def self.number_from string
8
+ parse_literal_within(string) || parse_phrase_within(string)
9
+ end
10
+
11
+ private
12
+
13
+ def self.parse_literal_within string
14
+ number = string.to_i
15
+ number if number != 0 or string.start_with?(0.to_s)
16
+ end
17
+
18
+ def self.parse_phrase_within string
8
19
  numbers = numbers_within string
9
20
  numbers.empty? ? raise(NoNumberFoundError, "No number found in string: #{string}") :
10
21
  total(numbers)
11
22
  end
12
-
13
- private
14
-
23
+
15
24
  def self.total numbers
16
25
  [10, 100, 1000, 1000000, 1000000000, 1000000000000].each do |power|
17
26
  combine(numbers).of_power(power).apply!
@@ -8,7 +8,7 @@ $:.unshift(File.dirname(__FILE__)) unless
8
8
  ].each {|file| require "numerouno/#{file}"}
9
9
 
10
10
  module Numerouno
11
- VERSION = '0.0.1'
11
+ VERSION = '0.1.0'
12
12
 
13
13
  def self.parse string
14
14
  Parser.number_from string
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: numerouno
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brent Snook
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-09 00:00:00 +02:00
12
+ date: 2009-06-07 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency