cheddar 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cheddar.rb +59 -0
- metadata +3 -2
data/lib/cheddar.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
class String
|
2
|
+
def human_to_number(slang_enabled=false)
|
3
|
+
mapping = {hundred: 100, thousand: 1000}
|
4
|
+
%w(m b tr quadr quint sext sept oct non dec undec duodec tredec quattuordec quindec sexdec septemdec octodec novemdec vigint).inject(1000) do |m,p|
|
5
|
+
mapping["#{p}illion"] = 1000 * m
|
6
|
+
end
|
7
|
+
|
8
|
+
if slang_enabled ||
|
9
|
+
(defined? String::SLANG_ENABLED &&
|
10
|
+
String::SLANG_ENABLED)
|
11
|
+
slang = {
|
12
|
+
bacon: 1,
|
13
|
+
benjamin: 100,
|
14
|
+
bills: 1,
|
15
|
+
bread: 1,
|
16
|
+
buck: 1,
|
17
|
+
cabbage: 1,
|
18
|
+
cash: 1,
|
19
|
+
cheddar: 1,
|
20
|
+
cheese: 1,
|
21
|
+
clams: 1,
|
22
|
+
dolla: 1,
|
23
|
+
dollar: 1,
|
24
|
+
dough: 1,
|
25
|
+
fin: 5,
|
26
|
+
green: 1,
|
27
|
+
greenback: 1,
|
28
|
+
jackson: 100,
|
29
|
+
kale: 1,
|
30
|
+
large: 100,
|
31
|
+
lettuce: 1,
|
32
|
+
loot: 1,
|
33
|
+
moolah: 1,
|
34
|
+
paper: 1,
|
35
|
+
potato: 1,
|
36
|
+
potatoes: 1,
|
37
|
+
sawbuck: 10,
|
38
|
+
scratch: 1,
|
39
|
+
scrip: 1,
|
40
|
+
twankie: 100,
|
41
|
+
'c-note' => 100,
|
42
|
+
'dead presidents' => 1,
|
43
|
+
'double sawbuck' => 20,
|
44
|
+
'long green' => 1
|
45
|
+
}
|
46
|
+
mapping.merge! slang
|
47
|
+
end
|
48
|
+
|
49
|
+
str = self.downcase
|
50
|
+
|
51
|
+
mapping.each do |num_name, value|
|
52
|
+
str.gsub!(num_name.to_s, "* #{value}")
|
53
|
+
end
|
54
|
+
|
55
|
+
str.gsub!(/[^\d\*\.]/, '')
|
56
|
+
|
57
|
+
eval(str)
|
58
|
+
end
|
59
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cheddar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -16,7 +16,8 @@ email: k.parnell@gmail.com
|
|
16
16
|
executables: []
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
|
-
files:
|
19
|
+
files:
|
20
|
+
- lib/cheddar.rb
|
20
21
|
homepage: http://github.com/kparnell/cheddar
|
21
22
|
licenses: []
|
22
23
|
post_install_message:
|