gci-class-extensions 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gci-class-extensions.rb +1 -1
- data/spec/gci-class-extensions_spec.rb +2 -5
- metadata +2 -2
data/lib/gci-class-extensions.rb
CHANGED
@@ -46,7 +46,7 @@ end
|
|
46
46
|
class String
|
47
47
|
def is_valid_dollar_amount?
|
48
48
|
# Optional parentheses or negative sign before or after the optional dollar sign, any number of digits and commas, followed by optional . and 1 or 2 digits, and optional close parentheses, with nothing on either side
|
49
|
-
strip =~ /^[\(-]?\$?[\(-]?[\d,]+(\.\d{1,2})
|
49
|
+
strip =~ /^[\(-]?\$?[\(-]?([\d,]+(\.\d{1,2})?|\.\d{1,2})\)?$/ ? true : false
|
50
50
|
end
|
51
51
|
|
52
52
|
def scrubbed_dollar_amount
|
@@ -88,6 +88,8 @@ end
|
|
88
88
|
|
89
89
|
describe String, "knowing whether it contains a valid dollar amount" do
|
90
90
|
valid_amounts = [
|
91
|
+
# less than a dollar
|
92
|
+
".50", "0.50", ".25",
|
91
93
|
# simple numbers with dollar signs
|
92
94
|
"$123", "$123.45", "$123,456", "$123,456.78",
|
93
95
|
# simple numbers without dollar signs
|
@@ -157,8 +159,3 @@ describe Float, "knowing its value as a percentage" do
|
|
157
159
|
end
|
158
160
|
end
|
159
161
|
|
160
|
-
# class Float
|
161
|
-
# def to_percentage(precision=2)
|
162
|
-
# (self * 100).round(precision)
|
163
|
-
# end
|
164
|
-
# end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gci-class-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Byrne
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-07-
|
12
|
+
date: 2010-07-29 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|