to_phone 0.0.4 → 0.0.5

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: 2e28d42fbd1444e99d0a06408fe6223956e5ed19
4
- data.tar.gz: 68105467596543688212c2b42cea659c229bc4b5
3
+ metadata.gz: 1f6ccc54082ccb63b2b5e92feb8676326f7cc130
4
+ data.tar.gz: a4be12bbf9af1fb19313cfb3f6515e93387e798d
5
5
  SHA512:
6
- metadata.gz: b9ca541220aca8d2d7c4fd36219710906b0cdeda726ff7a50c2faf04b9bed27aae1db7b4dba849bdaee2ada9a94e12bda1b4f3e514755a15a32a7b237cc65661
7
- data.tar.gz: e18ea86194b4f69d0353e27ad0493ba8a587f92ed8e7ad21e9eb818ae119df800749e9cc8d795a15df7abb05d9baf9cde6a5253ba6781a3d34959ca4a99d0d45
6
+ metadata.gz: f60211b20828b6a2bfecc29ef838807bac690da366408059688a7a80fe7778cc91a8dd1c3910c1bf419c40e8bba12e4ed97d2e455e278caa3ed94b1fb2213906
7
+ data.tar.gz: c1caa33e7d9a759a8828254d3ed6ca6e2069960c4cb1d143dbd704d4a3771a08de769833cd7b7579a15493ce4a4b06d8603eee5a09b01d94d704cccf8d487171
@@ -1,7 +1,12 @@
1
1
  class Float
2
-
2
+
3
3
  def to_phone country_code = '1'
4
4
  return ToPhone::Parser.to_phone(self.to_s, country_code)
5
5
  end
6
6
 
7
+ def to_phone_s country_code = '1'
8
+ phone = self.to_phone(country_code)
9
+ return phone.raw if phone
10
+ end
11
+
7
12
  end
@@ -4,4 +4,9 @@ class Integer
4
4
  return ToPhone::Parser.to_phone(self.to_s, country_code)
5
5
  end
6
6
 
7
+ def to_phone_s country_code = '1'
8
+ phone = self.to_phone(country_code)
9
+ return phone.raw if phone
10
+ end
11
+
7
12
  end
@@ -3,5 +3,9 @@ class NilClass
3
3
  def to_phone country_code = '1'
4
4
  return nil
5
5
  end
6
-
6
+
7
+ def to_phone_s country_code = '1'
8
+ return nil
9
+ end
10
+
7
11
  end
@@ -4,4 +4,9 @@ class String
4
4
  return ToPhone::Parser.to_phone(self, country_code)
5
5
  end
6
6
 
7
+ def to_phone_s country_code = '1'
8
+ phone = self.to_phone(country_code)
9
+ return phone.raw if phone
10
+ end
11
+
7
12
  end
data/lib/to_phone.rb CHANGED
@@ -13,8 +13,11 @@ module ToPhone
13
13
 
14
14
  def self.to_phone number, country_code = '1'
15
15
  begin
16
+ number = number.strip
17
+ country_code = country_code.strip
16
18
  country_code = '1' if country_code.nil? || country_code.empty?
17
19
  country_code = country_code.to_s
20
+ number = number[country_code.length..-1] if number[0..country_code.length] == country_code
18
21
  phone = Phoner::Phone.parse(number, country_code: country_code)
19
22
  return phone
20
23
  rescue Phoner::PhoneError
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: to_phone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Schreiber
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-14 00:00:00.000000000 Z
11
+ date: 2017-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: phone