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 +4 -4
- data/.gitignore +25 -25
- data/Gemfile +6 -6
- data/LICENSE +21 -21
- data/README.rdoc +56 -56
- data/Rakefile +27 -27
- data/bin/pnv +18 -15
- data/doc/PhoneNumberValidator/Validator.html +230 -231
- data/doc/PhoneNumberValidator.html +170 -171
- data/doc/PhoneNumberValidatorTest.html +198 -199
- data/doc/README_rdoc.html +159 -158
- data/doc/created.rid +6 -6
- data/doc/css/fonts.css +6 -6
- data/doc/index.html +154 -153
- data/doc/js/darkfish.js +7 -7
- data/doc/js/navigation.js.gz +0 -0
- data/doc/js/search_index.js.gz +0 -0
- data/doc/js/searcher.js +1 -0
- data/doc/js/searcher.js.gz +0 -0
- data/doc/table_of_contents.html +98 -97
- data/lib/phone_number_validator/validator.rb +34 -34
- data/lib/phone_number_validator.rb +25 -25
- data/phone_number_validator.gemspec +32 -32
- data/test/test_phone_number_validator.rb +24 -24
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ffaa61ae868acbf190d6d0e9accbeef5a2f337793d868b9c0ff07ead6d09c4f
|
4
|
+
data.tar.gz: '08f6e642c3b1054ee635c95e68aea0a51e9671cd6c587d3705f60b6e2ee16581'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
15
|
-
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
<script src="../js/
|
15
|
-
|
16
|
-
|
17
|
-
<link href="../css/
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
<
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
<a href="../table_of_contents.html#
|
32
|
-
<a href="../table_of_contents.html#
|
33
|
-
|
34
|
-
</div>
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
aria-
|
48
|
-
|
49
|
-
</
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
</
|
79
|
-
|
80
|
-
|
81
|
-
</
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
the
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
<span class="ruby-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
<span class="ruby-keyword">
|
202
|
-
|
203
|
-
<span class="ruby-
|
204
|
-
|
205
|
-
|
206
|
-
<span class="ruby-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
<
|
227
|
-
<p
|
228
|
-
<p>
|
229
|
-
|
230
|
-
|
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'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 = '+1 (949) 355-6244 ext. 198842')</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">'+1 (949) 355-6244 ext. 198842'</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">"\"%s\" is a valid phone number."</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">"\"%s\" is not a valid phone number."</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
|
+
|