duffy 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/duffy/string.rb +2 -3
- data/lib/duffy/version.rb +1 -1
- data/spec/string_spec.rb +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e0035fd1678d2bc2c4e6bcad1429a3fc9fc1fa9
|
4
|
+
data.tar.gz: ec504588e66ea7dfafa7090dede5b8d1e872e901
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6d56016fdbc81816dc4cb753777f730d819e7dad69b80690971afdb8fc3decf85c66687c5321ba3d2f42cfc69647bd8651cebb8424bbdb5d94d145044a7273f
|
7
|
+
data.tar.gz: f67d6f42090a26e34cb25385ba6594327e68abe329fd0e04374a826e24f94efda48b589cc9363efc94ced1f0de533222f13ec421aa12dfe970488d7676b0ae15
|
data/lib/duffy/string.rb
CHANGED
@@ -2,8 +2,7 @@
|
|
2
2
|
class String
|
3
3
|
|
4
4
|
def to_ssn
|
5
|
-
ssn = self.
|
6
|
-
ssn = "%09d" % ssn.to_i # now it has leading zeros
|
5
|
+
ssn = "%09d" % self.to_numeric.to_i # strips string of non zeros, and pads leading zeros
|
7
6
|
ssn[0..2] + "-" + ssn[3..4] + "-" + ssn[5..8] # now it's like 123-45-6789
|
8
7
|
end
|
9
8
|
|
@@ -25,7 +24,7 @@ class String
|
|
25
24
|
# serial: 0001 to 9999
|
26
25
|
def sanitize_ssn
|
27
26
|
begin
|
28
|
-
ssn = "%09d" % self.to_numeric
|
27
|
+
ssn = "%09d" % self.to_numeric.to_i
|
29
28
|
raise "Too Long" if ssn.length > 9
|
30
29
|
area, group, serial = ssn[0..2], ssn[3..4], ssn[5..8]
|
31
30
|
raise "Area Range Invalid" unless ("001" .. "665").cover?(area) or ("667" .. "899").cover?(area)
|
data/lib/duffy/version.rb
CHANGED
data/spec/string_spec.rb
CHANGED