epitools 0.4.24 → 0.4.25
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/epitools.gemspec +2 -2
- data/lib/epitools/numwords.rb +11 -11
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.25
|
data/epitools.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{epitools}
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.25"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["epitron"]
|
12
|
-
s.date = %q{2011-04-
|
12
|
+
s.date = %q{2011-04-15}
|
13
13
|
s.description = %q{Miscellaneous utility libraries to make my life easier.}
|
14
14
|
s.email = %q{chris@ill-logic.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/epitools/numwords.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'epitools/basetypes'
|
2
2
|
require 'bigdecimal'
|
3
|
+
require 'set'
|
3
4
|
|
4
5
|
class Numeric
|
5
6
|
|
@@ -9,11 +10,13 @@ class Numeric
|
|
9
10
|
|
10
11
|
NAMES_MEDIUM = [
|
11
12
|
"twenty", "thirty", "fourty", "fifty", "sixty", "seventy", "eighty", "ninety"
|
12
|
-
]
|
13
|
+
]
|
13
14
|
|
14
15
|
NAMES_LARGE = [
|
15
16
|
"thousand", "million", "billion", "trillion", "quadrillion", "quintillion", "sextillion", "septillion", "octillion", "nonillion", "decillion", "undecillion", "duodecillion", "tredecillion", "quattuordecillion", "quindecillion", "sexdecillion", "septendecillion", "octodecillion", "novemdecillion", "vigintillion", "unvigintillion", "duovigintillion", "trevigintillion", "quattuorvigintillion", "quinvigintillion", "sexvigintillion", "septenvigintillion", "octovigintillion", "novemvigintillion", "trigintillion", "untrigintillion", "duotrigintillion"
|
16
17
|
]
|
18
|
+
|
19
|
+
NAMES_LARGE_LOOKUP = Set.new(NAMES_LARGE)
|
17
20
|
|
18
21
|
|
19
22
|
#
|
@@ -98,24 +101,21 @@ class Numeric
|
|
98
101
|
# eg: 10.million #=> 10_000_000
|
99
102
|
#
|
100
103
|
def method_missing(meth, &block)
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
104
|
+
super
|
105
|
+
rescue NoMethodError
|
106
|
+
if NAMES_LARGE_LOOKUP.include? meth.to_s
|
107
|
+
magnitude = NAMES_LARGE.index(meth.to_s)
|
108
|
+
pow = (magnitude+1) * 3
|
109
|
+
factor = 10**pow
|
106
110
|
|
107
111
|
if is_a?(Float)
|
108
112
|
(BigDecimal(to_s) * factor).to_i
|
109
113
|
else
|
110
114
|
self * factor
|
111
115
|
end
|
112
|
-
|
113
116
|
else
|
114
|
-
|
115
|
-
super
|
116
|
-
|
117
|
+
raise NoMethodError.new(meth)
|
117
118
|
end
|
118
|
-
|
119
119
|
end
|
120
120
|
|
121
121
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: epitools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.4.
|
5
|
+
version: 0.4.25
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- epitron
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-04-
|
13
|
+
date: 2011-04-15 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|