to_phone 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99ab688e2f46a44c96e0744370272000530d2230
4
- data.tar.gz: 4a4aa0428ec4c65389137ec72e69c06b637ae9f3
3
+ metadata.gz: 2e28d42fbd1444e99d0a06408fe6223956e5ed19
4
+ data.tar.gz: 68105467596543688212c2b42cea659c229bc4b5
5
5
  SHA512:
6
- metadata.gz: 5055d4073a33d8d33fad1dd8771e47f16494a270910c8d8f1dfae87b7b02929e7471e9f6a87a453047c05a371124a605bb872b29da3489602078bdc86c2766cc
7
- data.tar.gz: 13067f62446d5a45e12c2e129cc25a9c6890662c7184b9563faf587c2d5edd7c2b1681ed74be16a78ac76ad97578d023a7f799ecaa40c1a017b4c98d5ac1e7c6
6
+ metadata.gz: b9ca541220aca8d2d7c4fd36219710906b0cdeda726ff7a50c2faf04b9bed27aae1db7b4dba849bdaee2ada9a94e12bda1b4f3e514755a15a32a7b237cc65661
7
+ data.tar.gz: e18ea86194b4f69d0353e27ad0493ba8a587f92ed8e7ad21e9eb818ae119df800749e9cc8d795a15df7abb05d9baf9cde6a5253ba6781a3d34959ca4a99d0d45
@@ -0,0 +1,7 @@
1
+ class Float
2
+
3
+ def to_phone country_code = '1'
4
+ return ToPhone::Parser.to_phone(self.to_s, country_code)
5
+ end
6
+
7
+ end
@@ -0,0 +1,7 @@
1
+ class Integer
2
+
3
+ def to_phone country_code = '1'
4
+ return ToPhone::Parser.to_phone(self.to_s, country_code)
5
+ end
6
+
7
+ end
@@ -0,0 +1,7 @@
1
+ class NilClass
2
+
3
+ def to_phone country_code = '1'
4
+ return nil
5
+ end
6
+
7
+ end
@@ -0,0 +1,11 @@
1
+ class Phoner::Phone
2
+
3
+ def formatted
4
+ return self.country_code == '1' ? self.format(:us) : self.format(:europe)
5
+ end
6
+
7
+ def raw
8
+ return self.to_s
9
+ end
10
+
11
+ end
@@ -0,0 +1,7 @@
1
+ class String
2
+
3
+ def to_phone country_code = '1'
4
+ return ToPhone::Parser.to_phone(self, country_code)
5
+ end
6
+
7
+ end
data/lib/to_phone.rb CHANGED
@@ -1,42 +1,27 @@
1
1
  require 'phone'
2
2
 
3
- class String
4
-
5
- def to_phone country_code = '1'
6
- begin
7
- country_code = '1' if country_code.nil? || country_code.empty?
8
- country_code = country_code.to_s
9
- phone = Phoner::Phone.parse(self, country_code: country_code)
10
- return phone
11
- rescue Phoner::PhoneError
12
- return nil
3
+ require 'extensions/string'
4
+ require 'extensions/float'
5
+ require 'extensions/integer'
6
+ require 'extensions/nil'
7
+ require 'extensions/phone'
8
+
9
+
10
+ module ToPhone
11
+
12
+ class Parser
13
+
14
+ def self.to_phone number, country_code = '1'
15
+ begin
16
+ country_code = '1' if country_code.nil? || country_code.empty?
17
+ country_code = country_code.to_s
18
+ phone = Phoner::Phone.parse(number, country_code: country_code)
19
+ return phone
20
+ rescue Phoner::PhoneError
21
+ return nil
22
+ end
13
23
  end
14
- end
15
-
16
- end
17
-
18
- class Integer
19
- def to_phone country_code = '1'
20
- self.to_s.to_phone(country_code)
21
- end
22
- end
23
-
24
- class Float
25
- def to_phone country_code = '1'
26
- self.to_s.to_phone(country_code)
27
- end
28
- end
29
-
30
- class NilClass
31
- def to_phone country_code = '1'
32
- return nil
33
- end
34
- end
35
-
36
- class Phoner::Phone
37
24
 
38
- def local_f
39
- return self.country_code == '1' ? self.format(:us) : self.format(:europe)
40
25
  end
41
26
 
42
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: to_phone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Schreiber
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2.0
19
+ version: '1.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.2.0
26
+ version: '1.2'
27
27
  description: Easily convert strings and numbers to Phone objects using .to_phone,
28
28
  plus some other cool Phone extensions!
29
29
  email: w@lxv.io
@@ -31,6 +31,11 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
+ - lib/extensions/float.rb
35
+ - lib/extensions/integer.rb
36
+ - lib/extensions/nil.rb
37
+ - lib/extensions/phone.rb
38
+ - lib/extensions/string.rb
34
39
  - lib/to_phone.rb
35
40
  homepage: https://rubygems.org/gems/to_phone
36
41
  licenses: