to_phone 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/extensions/float.rb +7 -0
- data/lib/extensions/integer.rb +7 -0
- data/lib/extensions/nil.rb +7 -0
- data/lib/extensions/phone.rb +11 -0
- data/lib/extensions/string.rb +7 -0
- data/lib/to_phone.rb +20 -35
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e28d42fbd1444e99d0a06408fe6223956e5ed19
|
4
|
+
data.tar.gz: 68105467596543688212c2b42cea659c229bc4b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9ca541220aca8d2d7c4fd36219710906b0cdeda726ff7a50c2faf04b9bed27aae1db7b4dba849bdaee2ada9a94e12bda1b4f3e514755a15a32a7b237cc65661
|
7
|
+
data.tar.gz: e18ea86194b4f69d0353e27ad0493ba8a587f92ed8e7ad21e9eb818ae119df800749e9cc8d795a15df7abb05d9baf9cde6a5253ba6781a3d34959ca4a99d0d45
|
data/lib/to_phone.rb
CHANGED
@@ -1,42 +1,27 @@
|
|
1
1
|
require 'phone'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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.
|
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
|
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
|
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:
|