phone_number_validator 0.4.2 → 0.4.3

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
  SHA256:
3
- metadata.gz: b704cf1dce4664444f4d38485ec22b04ac17221ed3ce1365f290f0ccd90afac1
4
- data.tar.gz: 58ef10cd141806f33ff9534e1fb936b8a0c2525a3c955d3b701182f2d6d3aab2
3
+ metadata.gz: 6ffaa61ae868acbf190d6d0e9accbeef5a2f337793d868b9c0ff07ead6d09c4f
4
+ data.tar.gz: '08f6e642c3b1054ee635c95e68aea0a51e9671cd6c587d3705f60b6e2ee16581'
5
5
  SHA512:
6
- metadata.gz: 77bbf4040b08c0ede3b808dcbabeefb46a3d72906a149200b753de7be4ac0aa36b309ba05892f9c25306c9ddf684a64e841c6a9ae0986ee4aaf4ff02bdfe3536
7
- data.tar.gz: 90f682110f4b64e790cc92f4df5daa78ce5848a73eb14d460b07088a5f10ccc413d614dd2aec63122a581571a621398947699021defa3986db1cec1f99a2f8f5
6
+ metadata.gz: 7a426c9fc052597adc547cb20406530e6e8497d069bc94676d384b192ada078cea76b88207977796da430c7a69a3b019790c3d57dd23dabc543557f6d03fb159
7
+ data.tar.gz: 9f8804ed12b15d71d0fdb636e2d51fe8dd53e4cab546b4a0d7001af80d2c5c2c326f7173f4415a6f9aacdc809e04a292723542895b048177c600b07ce546e3b7
data/.gitignore CHANGED
@@ -1,25 +1,25 @@
1
- # System File(s)/Folder(s)
2
- .DS_Store
3
- Thumbs.db
4
- _MACOSX
5
-
6
- # Editor File(s)/Folder(s)
7
- *.code-workspace
8
- *.sublime-project
9
- *.sublime-workspace
10
- .vscode
11
-
12
- # Generated Files
13
- *.gem
14
- *.lock
15
-
16
- # Executables
17
- *.bat
18
- *.sh
19
-
20
- # if gitignore is not working, try this:
21
- #
22
- # git rm -r --cached .
23
- # git add .
24
- # git commit -m "fixed untracked files"
25
- # git push
1
+ # System File(s)/Folder(s)
2
+ .DS_Store
3
+ Thumbs.db
4
+ _MACOSX
5
+
6
+ # Editor File(s)/Folder(s)
7
+ *.code-workspace
8
+ *.sublime-project
9
+ *.sublime-workspace
10
+ .vscode
11
+
12
+ # Generated Files
13
+ *.gem
14
+ *.lock
15
+
16
+ # Executables
17
+ *.bat
18
+ *.sh
19
+
20
+ # if gitignore is not working, try this:
21
+ #
22
+ # git rm -r --cached .
23
+ # git add .
24
+ # git commit -m "fixed untracked files"
25
+ # git push
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
- source 'https://rubygems.org'
2
- platform :ruby do
3
- gemspec
4
- gem 'rdoc', '~> 6.0', '>= 6.0.4'
5
- gem 'rake', '~> 11.2', '>= 11.2.2'
6
- end
1
+ source 'https://rubygems.org'
2
+ platform :ruby do
3
+ gemspec
4
+ gem 'rdoc', '~> 6.0', '>= 6.0.4'
5
+ gem 'rake', '~> 11.2', '>= 11.2.2'
6
+ end
data/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2018 bag33188
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2018 bag33188
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.rdoc CHANGED
@@ -1,56 +1,56 @@
1
- = Phone Number Validator
2
-
3
- == About
4
-
5
- This app is a US phone number-validating RubyGem.
6
-
7
- It uses a complex regular expression to validate any United States phone number.
8
-
9
- === Regular Expression
10
-
11
- This gem uses the following regular expression:
12
-
13
- # US Phone Numbers
14
- /^(?:(?:[2-9]11)|(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:\x20+|#|x\.?|ext\.?|extension)\s*(\d+))?)$/i
15
- # Regex Flags: i (ignore case)
16
-
17
- == Installing
18
-
19
- $ gem install phone_number_validator
20
-
21
- === Install Required Gems/Dependencies
22
-
23
- $ bundle install
24
-
25
- === Updateing Required Gems/Dependencies
26
-
27
- $ bundle update
28
-
29
- == Uninstalling
30
-
31
- $ gem uninstall phone_number_validator
32
-
33
- == Testing
34
-
35
- $ rake test
36
-
37
- == Usage
38
-
39
- === In command line
40
-
41
- $ pnv "+1 (949) 355-6244 ext. 198842"
42
- => "+1 (949) 355-6244 ext. 198842" is a valid phone number.
43
- => true
44
-
45
- === In Ruby code
46
-
47
- require 'phone_number_validator'
48
-
49
- check_phone_number = PhoneNumberValidator.validate_phone_number('+1 (949) 355-6244 ext. 198842')
50
-
51
- print check_phone_number
52
-
53
- ==== Output
54
-
55
- => "+1 (949) 355-6244 ext. 198842" is a valid phone number.
56
- => true
1
+ = Phone Number Validator
2
+
3
+ == About
4
+
5
+ This app is a US phone number-validating RubyGem.
6
+
7
+ It uses a complex regular expression to validate any United States phone number.
8
+
9
+ === Regular Expression
10
+
11
+ This gem uses the following regular expression:
12
+
13
+ # US Phone Numbers
14
+ /^(?:(?:[2-9]11)|(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:\x20+|#|x\.?|ext\.?|extension)\s*(\d+))?)$/i
15
+ # Regex Flags: i (ignore case)
16
+
17
+ == Installing
18
+
19
+ $ gem install phone_number_validator
20
+
21
+ === Install Required Gems/Dependencies
22
+
23
+ $ bundle install
24
+
25
+ === Updateing Required Gems/Dependencies
26
+
27
+ $ bundle update
28
+
29
+ == Uninstalling
30
+
31
+ $ gem uninstall phone_number_validator
32
+
33
+ == Testing
34
+
35
+ $ rake test
36
+
37
+ == Usage
38
+
39
+ === In command line
40
+
41
+ $ pnv "+1 (949) 355-6244 ext. 198842"
42
+ => "+1 (949) 355-6244 ext. 198842" is a valid phone number.
43
+ => true
44
+
45
+ === In Ruby code
46
+
47
+ require 'phone_number_validator'
48
+
49
+ check_phone_number = PhoneNumberValidator.validate_phone_number('+1 (949) 355-6244 ext. 198842')
50
+
51
+ print check_phone_number
52
+
53
+ ==== Output
54
+
55
+ => "+1 (949) 355-6244 ext. 198842" is a valid phone number.
56
+ => true
data/Rakefile CHANGED
@@ -1,27 +1,27 @@
1
- require 'rake/testtask'
2
-
3
- Rake::TestTask.new do |test|
4
- test.libs << 'test'
5
- end
6
-
7
- desc 'Run tests'
8
- task :default => :test
9
-
10
- require 'rdoc/task'
11
-
12
- RDoc::Task.new do |rdoc|
13
- rdoc.main = 'README.rdoc'
14
- rdoc.title = 'Phone Number Validator'
15
- rdoc.rdoc_dir = 'doc'
16
- rdoc.rdoc_files.include('README.rdoc', 'lib/*.rb', 'lib/**/*.rb', 'test/*.rb', 'bin/*')
17
- end
18
-
19
- # for Windows
20
- task :deldocw do
21
- `RMDIR /S /Q "doc"`
22
- end
23
-
24
- # for Unix
25
- task :deldocx do
26
- `rm -rf doc`
27
- end
1
+ require 'rake/testtask'
2
+
3
+ Rake::TestTask.new do |test|
4
+ test.libs << 'test'
5
+ end
6
+
7
+ desc 'Run tests'
8
+ task :default => :test
9
+
10
+ require 'rdoc/task'
11
+
12
+ RDoc::Task.new do |rdoc|
13
+ rdoc.main = 'README.rdoc'
14
+ rdoc.title = 'Phone Number Validator'
15
+ rdoc.rdoc_dir = 'doc'
16
+ rdoc.rdoc_files.include('README.rdoc', 'lib/*.rb', 'lib/**/*.rb', 'test/*.rb', 'bin/*')
17
+ end
18
+
19
+ # for Windows
20
+ task :deldocw do
21
+ `RMDIR /S /Q "doc"`
22
+ end
23
+
24
+ # for Unix
25
+ task :deldocx do
26
+ `rm -rf doc`
27
+ end
data/bin/pnv CHANGED
@@ -1,15 +1,18 @@
1
- #!/usr/bin/env ruby
2
-
3
- =begin
4
- |======================|
5
- | PhoneNumberValidator |
6
- |----------------------|
7
- | Made by: bag33188 |
8
- |======================|
9
- =end
10
-
11
- require 'phone_number_validator'
12
-
13
- print "\r\n"
14
- # execute validator
15
- puts(PhoneNumberValidator.validate_phone_number(ARGV[0]))
1
+ #!/usr/bin/env ruby
2
+
3
+ =begin
4
+ |======================|
5
+ | PhoneNumberValidator |
6
+ |----------------------|
7
+ | Made by: bag33188 |
8
+ |======================|
9
+ =end
10
+
11
+ require 'phone_number_validator'
12
+
13
+ print "\r\n"
14
+
15
+ # execute validator
16
+ puts(PhoneNumberValidator.validate_phone_number(ARGV[0]))
17
+
18
+ print "\r\n"
@@ -1,231 +1,230 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <meta charset="UTF-8">
6
-
7
- <title>class PhoneNumberValidator::Validator - Phone Number Validator</title>
8
-
9
- <script type="text/javascript">
10
- var rdoc_rel_prefix = "../";
11
- </script>
12
-
13
- <script src="../js/jquery.js"></script>
14
- <script src="../js/darkfish.js"></script>
15
-
16
- <link href="../css/fonts.css" rel="stylesheet">
17
- <link href="../css/rdoc.css" rel="stylesheet">
18
-
19
-
20
-
21
- <body id="top" role="document" class="class">
22
- <nav role="navigation">
23
- <div id="project-navigation">
24
- <div id="home-section" role="region" title="Quick navigation" class="nav-section">
25
- <h2>
26
- <a href="../index.html" rel="home">Home</a>
27
- </h2>
28
-
29
- <div id="table-of-contents-navigation">
30
- <a href="../table_of_contents.html#pages">Pages</a>
31
- <a href="../table_of_contents.html#classes">Classes</a>
32
- <a href="../table_of_contents.html#methods">Methods</a>
33
- </div>
34
- </div>
35
-
36
- <div id="search-section" role="search" class="project-section initially-hidden">
37
- <form action="#" method="get" accept-charset="utf-8">
38
- <div id="search-field-wrapper">
39
- <input id="search-field" role="combobox" aria-label="Search"
40
- aria-autocomplete="list" aria-controls="search-results"
41
- type="text" name="search" placeholder="Search" spellcheck="false"
42
- title="Type to search, Up and Down to navigate, Enter to load">
43
- </div>
44
-
45
- <ul id="search-results" aria-label="Search Results"
46
- aria-busy="false" aria-expanded="false"
47
- aria-atomic="false" class="initially-hidden"></ul>
48
- </form>
49
- </div>
50
-
51
- </div>
52
-
53
-
54
-
55
- <div id="class-metadata">
56
-
57
- <div id="parent-class-section" class="nav-section">
58
- <h3>Parent</h3>
59
-
60
-
61
- <p class="link">Object
62
-
63
- </div>
64
-
65
-
66
-
67
- <!-- Method Quickref -->
68
- <div id="method-list-section" class="nav-section">
69
- <h3>Methods</h3>
70
-
71
- <ul class="link-list" role="directory">
72
-
73
- <li ><a href="#method-c-new">::new</a>
74
-
75
- <li ><a href="#method-i-validate_phone_number">#validate_phone_number</a>
76
-
77
- </ul>
78
- </div>
79
-
80
- </div>
81
- </nav>
82
-
83
- <main role="main" aria-labelledby="class-PhoneNumberValidator::Validator">
84
- <h1 id="class-PhoneNumberValidator::Validator" class="class">
85
- class PhoneNumberValidator::Validator
86
- </h1>
87
-
88
- <section class="description">
89
-
90
- <p>This class does all of the matching and checking work for the validation of
91
- the phone number.</p>
92
-
93
- </section>
94
-
95
-
96
-
97
-
98
- <section id="5Buntitled-5D" class="documentation-section">
99
-
100
-
101
-
102
-
103
-
104
- <section class="constants-list">
105
- <header>
106
- <h3>Constants</h3>
107
- </header>
108
- <dl>
109
-
110
- <dt id="PHONE_NUMBER_REGEX">PHONE_NUMBER_REGEX
111
-
112
- <dd><p>The regex pattern for validating US phone numbers</p>
113
-
114
- <p>Regular Expression tested using <a
115
- href="https://regexr.com/">regexr.com</a></p>
116
-
117
- <p>The regular expression used can be found in <em>README.rdoc</em> on the
118
- documentation&#39;s home page</p>
119
-
120
-
121
- </dl>
122
- </section>
123
-
124
-
125
-
126
-
127
-
128
- <section id="public-class-5Buntitled-5D-method-details" class="method-section">
129
- <header>
130
- <h3>Public Class Methods</h3>
131
- </header>
132
-
133
-
134
- <div id="method-c-new" class="method-detail ">
135
-
136
- <div class="method-heading">
137
- <span class="method-name">new</span><span
138
- class="method-args">(phone_number = '+1 (949) 355-6244 ext. 198842')</span>
139
-
140
- <span class="method-click-advice">click to toggle source</span>
141
-
142
- </div>
143
-
144
-
145
- <div class="method-description">
146
-
147
- <p>initializes the <strong>@phone_number</strong> instance variable</p>
148
-
149
-
150
-
151
-
152
- <div class="method-source-code" id="new-source">
153
- <pre><span class="ruby-comment"># File lib/phone_number_validator/validator.rb, line 15</span>
154
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">phone_number</span> = <span class="ruby-string">&#39;+1 (949) 355-6244 ext. 198842&#39;</span>)
155
- <span class="ruby-ivar">@phone_number</span> = <span class="ruby-identifier">phone_number</span>
156
- <span class="ruby-keyword">end</span></pre>
157
- </div>
158
-
159
- </div>
160
-
161
-
162
-
163
-
164
- </div>
165
-
166
-
167
- </section>
168
-
169
- <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
170
- <header>
171
- <h3>Public Instance Methods</h3>
172
- </header>
173
-
174
-
175
- <div id="method-i-validate_phone_number" class="method-detail ">
176
-
177
- <div class="method-heading">
178
- <span class="method-name">validate_phone_number</span><span
179
- class="method-args">()</span>
180
-
181
- <span class="method-click-advice">click to toggle source</span>
182
-
183
- </div>
184
-
185
-
186
- <div class="method-description">
187
-
188
- <p>Checks to see if the phone number the user entered is valid by testing
189
- regex the pattern with the phone number</p>
190
-
191
- <p><strong>Return Type:</strong></p>
192
-
193
- <pre class="ruby"><span class="ruby-identifier">boolean</span>
194
- </pre>
195
-
196
-
197
-
198
-
199
- <div class="method-source-code" id="validate_phone_number-source">
200
- <pre><span class="ruby-comment"># File lib/phone_number_validator/validator.rb, line 25</span>
201
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">validate_phone_number</span>
202
- <span class="ruby-keyword">if</span> (<span class="ruby-ivar">@phone_number</span>.<span class="ruby-identifier">match</span>(<span class="ruby-constant">PHONE_NUMBER_REGEX</span>))
203
- <span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;\&quot;%s\&quot; is a valid phone number.&quot;</span> <span class="ruby-operator">%</span> <span class="ruby-ivar">@phone_number</span>
204
- <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span>
205
- <span class="ruby-keyword">else</span>
206
- <span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;\&quot;%s\&quot; is not a valid phone number.&quot;</span> <span class="ruby-operator">%</span> <span class="ruby-ivar">@phone_number</span>
207
- <span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span>
208
- <span class="ruby-keyword">end</span>
209
- <span class="ruby-keyword">end</span></pre>
210
- </div>
211
-
212
- </div>
213
-
214
-
215
-
216
-
217
- </div>
218
-
219
-
220
- </section>
221
-
222
- </section>
223
- </main>
224
-
225
-
226
- <footer id="validator-badges" role="contentinfo">
227
- <p><a href="http://validator.w3.org/check/referer">Validate</a>
228
- <p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.1.
229
- <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
230
- </footer>
231
-
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>class PhoneNumberValidator::Validator - Phone Number Validator</title>
8
+
9
+ <script type="text/javascript">
10
+ var rdoc_rel_prefix = "../";
11
+ var index_rel_prefix = "../";
12
+ </script>
13
+
14
+ <script src="../js/jquery.js"></script>
15
+ <script src="../js/darkfish.js"></script>
16
+
17
+ <link href="../css/fonts.css" rel="stylesheet">
18
+ <link href="../css/rdoc.css" rel="stylesheet">
19
+
20
+
21
+
22
+ <body id="top" role="document" class="class">
23
+ <nav role="navigation">
24
+ <div id="project-navigation">
25
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
26
+ <h2>
27
+ <a href="../index.html" rel="home">Home</a>
28
+ </h2>
29
+
30
+ <div id="table-of-contents-navigation">
31
+ <a href="../table_of_contents.html#pages">Pages</a>
32
+ <a href="../table_of_contents.html#classes">Classes</a>
33
+ <a href="../table_of_contents.html#methods">Methods</a>
34
+ </div>
35
+ </div>
36
+
37
+ <div id="search-section" role="search" class="project-section initially-hidden">
38
+ <form action="#" method="get" accept-charset="utf-8">
39
+ <div id="search-field-wrapper">
40
+ <input id="search-field" role="combobox" aria-label="Search"
41
+ aria-autocomplete="list" aria-controls="search-results"
42
+ type="text" name="search" placeholder="Search" spellcheck="false"
43
+ title="Type to search, Up and Down to navigate, Enter to load">
44
+ </div>
45
+
46
+ <ul id="search-results" aria-label="Search Results"
47
+ aria-busy="false" aria-expanded="false"
48
+ aria-atomic="false" class="initially-hidden"></ul>
49
+ </form>
50
+ </div>
51
+
52
+ </div>
53
+
54
+
55
+
56
+ <div id="class-metadata">
57
+
58
+ <div id="parent-class-section" class="nav-section">
59
+ <h3>Parent</h3>
60
+
61
+
62
+ <p class="link">Object
63
+
64
+ </div>
65
+
66
+
67
+
68
+ <!-- Method Quickref -->
69
+ <div id="method-list-section" class="nav-section">
70
+ <h3>Methods</h3>
71
+
72
+ <ul class="link-list" role="directory">
73
+
74
+ <li ><a href="#method-c-new">::new</a>
75
+
76
+ <li ><a href="#method-i-validate_phone_number">#validate_phone_number</a>
77
+
78
+ </ul>
79
+ </div>
80
+
81
+ </div>
82
+ </nav>
83
+
84
+ <main role="main" aria-labelledby="class-PhoneNumberValidator::Validator">
85
+ <h1 id="class-PhoneNumberValidator::Validator" class="class">
86
+ class PhoneNumberValidator::Validator
87
+ </h1>
88
+
89
+ <section class="description">
90
+
91
+ <p>This class does all of the matching and checking work for the validation of
92
+ the phone number.</p>
93
+
94
+ </section>
95
+
96
+
97
+ <section id="5Buntitled-5D" class="documentation-section">
98
+
99
+
100
+
101
+
102
+
103
+ <section class="constants-list">
104
+ <header>
105
+ <h3>Constants</h3>
106
+ </header>
107
+ <dl>
108
+
109
+ <dt id="PHONE_NUMBER_REGEX">PHONE_NUMBER_REGEX
110
+
111
+ <dd><p>The regex pattern for validating US phone numbers</p>
112
+
113
+ <p>Regular Expression tested using <a
114
+ href="https://regexr.com/">regexr.com</a></p>
115
+
116
+ <p>The regular expression used can be found in <em>README.rdoc</em> on the
117
+ documentation&#39;s home page</p>
118
+
119
+
120
+ </dl>
121
+ </section>
122
+
123
+
124
+
125
+
126
+
127
+ <section id="public-class-5Buntitled-5D-method-details" class="method-section">
128
+ <header>
129
+ <h3>Public Class Methods</h3>
130
+ </header>
131
+
132
+
133
+ <div id="method-c-new" class="method-detail ">
134
+
135
+ <div class="method-heading">
136
+ <span class="method-name">new</span><span
137
+ class="method-args">(phone_number = &#39;+1 (949) 355-6244 ext. 198842&#39;)</span>
138
+
139
+ <span class="method-click-advice">click to toggle source</span>
140
+
141
+ </div>
142
+
143
+
144
+ <div class="method-description">
145
+
146
+ <p>initializes the <strong>@phone_number</strong> instance variable</p>
147
+
148
+
149
+
150
+
151
+ <div class="method-source-code" id="new-source">
152
+ <pre><span class="ruby-comment"># File lib/phone_number_validator/validator.rb, line 15</span>
153
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">phone_number</span> = <span class="ruby-string">&#39;+1 (949) 355-6244 ext. 198842&#39;</span>)
154
+ <span class="ruby-ivar">@phone_number</span> = <span class="ruby-identifier">phone_number</span>
155
+ <span class="ruby-keyword">end</span></pre>
156
+ </div>
157
+
158
+ </div>
159
+
160
+
161
+
162
+
163
+ </div>
164
+
165
+
166
+ </section>
167
+
168
+ <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
169
+ <header>
170
+ <h3>Public Instance Methods</h3>
171
+ </header>
172
+
173
+
174
+ <div id="method-i-validate_phone_number" class="method-detail ">
175
+
176
+ <div class="method-heading">
177
+ <span class="method-name">validate_phone_number</span><span
178
+ class="method-args">()</span>
179
+
180
+ <span class="method-click-advice">click to toggle source</span>
181
+
182
+ </div>
183
+
184
+
185
+ <div class="method-description">
186
+
187
+ <p>Checks to see if the phone number the user entered is valid by testing
188
+ regex the pattern with the phone number</p>
189
+
190
+ <p><strong>Return Type:</strong></p>
191
+
192
+ <pre class="ruby"><span class="ruby-identifier">boolean</span>
193
+ </pre>
194
+
195
+
196
+
197
+
198
+ <div class="method-source-code" id="validate_phone_number-source">
199
+ <pre><span class="ruby-comment"># File lib/phone_number_validator/validator.rb, line 25</span>
200
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">validate_phone_number</span>
201
+ <span class="ruby-keyword">if</span> (<span class="ruby-ivar">@phone_number</span>.<span class="ruby-identifier">match</span>(<span class="ruby-constant">PHONE_NUMBER_REGEX</span>))
202
+ <span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;\&quot;%s\&quot; is a valid phone number.&quot;</span> <span class="ruby-operator">%</span> <span class="ruby-ivar">@phone_number</span>
203
+ <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span>
204
+ <span class="ruby-keyword">else</span>
205
+ <span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;\&quot;%s\&quot; is not a valid phone number.&quot;</span> <span class="ruby-operator">%</span> <span class="ruby-ivar">@phone_number</span>
206
+ <span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span>
207
+ <span class="ruby-keyword">end</span>
208
+ <span class="ruby-keyword">end</span></pre>
209
+ </div>
210
+
211
+ </div>
212
+
213
+
214
+
215
+
216
+ </div>
217
+
218
+
219
+ </section>
220
+
221
+ </section>
222
+ </main>
223
+
224
+
225
+ <footer id="validator-badges" role="contentinfo">
226
+ <p><a href="https://validator.w3.org/check/referer">Validate</a>
227
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.0.4.
228
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
229
+ </footer>
230
+