to_phone 0.0.2

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/to_phone.rb +42 -0
  3. metadata +59 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e4b44714a93ac38887449b1888e60917921f7d31
4
+ data.tar.gz: d8dea6172feee5a4065f35d6d0dc3bae0df7c8e3
5
+ SHA512:
6
+ metadata.gz: 297f735b76dcccc6511224811ad035387bec92c90f3236d2bc66d2014672f5a2da51d5bca1e1cf8e11c194b9e05ab727dbc0cf8fbc9c1218bd9102a02274f272
7
+ data.tar.gz: 670f4f6ee114938a8c37471851f87c0a2abf8718ae75ad625caaa3f652250d23b2f09c4c7e531075acf3c6b28592de68dc36edc9fa28dfe883fc1b5868e37a8a
data/lib/to_phone.rb ADDED
@@ -0,0 +1,42 @@
1
+ require 'phone'
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
13
+ 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
+
38
+ def local_f
39
+ return self.country_code == '1' ? self.format(:us) : self.format(:europe)
40
+ end
41
+
42
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: to_phone
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Will Schreiber
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-03-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: phone
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Easily convert strings and numbers to Phone objects using .to_phone,
28
+ plus some other cool Phone extensions!
29
+ email: w@lxv.io
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - lib/to_phone.rb
35
+ homepage: https://rubygems.org/gems/to_phone
36
+ licenses:
37
+ - MIT
38
+ metadata: {}
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubyforge_project:
55
+ rubygems_version: 2.6.8
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: Use .to_phone to get Phone objects.
59
+ test_files: []