phone_number_validator 0.0.0
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 +7 -0
- data/.gitignore +25 -0
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/README.rdoc +94 -0
- data/Rakefile +27 -0
- data/bin/phone_number_validator +13 -0
- data/doc/PhoneNumberValidator.html +164 -0
- data/doc/PhoneNumberValidator/Validator.html +216 -0
- data/doc/PhoneNumberValidatorTest.html +190 -0
- data/doc/README_rdoc.html +206 -0
- data/doc/created.rid +6 -0
- data/doc/css/fonts.css +167 -0
- data/doc/css/rdoc.css +590 -0
- data/doc/fonts/Lato-Light.ttf +0 -0
- data/doc/fonts/Lato-LightItalic.ttf +0 -0
- data/doc/fonts/Lato-Regular.ttf +0 -0
- data/doc/fonts/Lato-RegularItalic.ttf +0 -0
- data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
- data/doc/images/add.png +0 -0
- data/doc/images/arrow_up.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +193 -0
- data/doc/js/darkfish.js +161 -0
- data/doc/js/jquery.js +4 -0
- data/doc/js/navigation.js +142 -0
- data/doc/js/navigation.js.gz +0 -0
- data/doc/js/search.js +109 -0
- data/doc/js/search_index.js +1 -0
- data/doc/js/search_index.js.gz +0 -0
- data/doc/js/searcher.js +228 -0
- data/doc/js/searcher.js.gz +0 -0
- data/doc/table_of_contents.html +105 -0
- data/lib/phone_number_validator.rb +19 -0
- data/lib/phone_number_validator/validator.rb +15 -0
- data/phone_number_validator.gemspec +27 -0
- data/test/test_phone_number_validator.rb +13 -0
- metadata +150 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d78eddf37f0f8ba4257338f2bbc4a86a924ae564d9538da5df18ee0173ed9481
|
4
|
+
data.tar.gz: 7ab2282b16c172a569be27923aeadb0d4c0669ac77b2c3c4ecc34cea53adbb81
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7d58887ce1e729b92ebc21dd395e1a936cde5f01e1cba71d93f8618407d0d0ed94324384ec0915bf3b3cf7afcf43b5a151407b3d40e7064bca0be93e53115b34
|
7
|
+
data.tar.gz: 2e4375ae46f35f0cf2b98afadd6ddca3a1391dbdbeaa28e1b82763bbe90c6bf9572826882881b37326f67de82db7d82be3738e95f99545857fff9b12af7b2da8
|
data/.gitignore
ADDED
@@ -0,0 +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
|
+
RPS-*
|
16
|
+
|
17
|
+
# Other
|
18
|
+
*.bat
|
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
ADDED
data/LICENSE
ADDED
@@ -0,0 +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.
|
data/README.rdoc
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
= Phone Number Validator
|
2
|
+
|
3
|
+
== About
|
4
|
+
|
5
|
+
This app is a US phone number-validating RubyGem.
|
6
|
+
|
7
|
+
== Installing
|
8
|
+
|
9
|
+
$ gem install phone_number_validator
|
10
|
+
|
11
|
+
=== Install Required Gems
|
12
|
+
|
13
|
+
$ bundle install
|
14
|
+
|
15
|
+
== Uninstalling
|
16
|
+
|
17
|
+
$ gem uninstall phone_number_validator
|
18
|
+
|
19
|
+
== Testing
|
20
|
+
|
21
|
+
$ rake test
|
22
|
+
|
23
|
+
== Usage
|
24
|
+
|
25
|
+
=== In command line
|
26
|
+
|
27
|
+
$ phone_number_validator '+1 (949) 355-6244 ext. 198842'
|
28
|
+
=> '+1 (949) 355-6244 ext. 198842' is a valid phone number.'
|
29
|
+
=> true
|
30
|
+
|
31
|
+
=== In Ruby code
|
32
|
+
|
33
|
+
require 'phone_number_validator'
|
34
|
+
|
35
|
+
check_phone_number = PhoneNumberValidator.validate_phone_number('+1 (949) 355-6244 ext. 198842')
|
36
|
+
|
37
|
+
print(check_phone_number)
|
38
|
+
|
39
|
+
==== Output
|
40
|
+
|
41
|
+
=> '+1 (949) 355-6244 ext. 198842' is a valid phone number.'
|
42
|
+
=> true
|
43
|
+
|
44
|
+
== Download/Install Ruby and RubyGems (on all OS)
|
45
|
+
|
46
|
+
=== Windows
|
47
|
+
|
48
|
+
==== Ruby
|
49
|
+
|
50
|
+
Download and install the RubyInstaller from {RubyInstaller's website}[https://rubyinstaller.org/].
|
51
|
+
|
52
|
+
==== RubyGems
|
53
|
+
|
54
|
+
Download and extract the zip file from the {RubyGems download page}[https://rubygems.org/pages/download].
|
55
|
+
|
56
|
+
Then run the following:
|
57
|
+
|
58
|
+
$ cd <path/to/extracted/zip>
|
59
|
+
$ ruby setup.rb
|
60
|
+
|
61
|
+
=== OSX
|
62
|
+
|
63
|
+
==== Ruby
|
64
|
+
|
65
|
+
Run the following:
|
66
|
+
|
67
|
+
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
68
|
+
$ sudo brew install ruby
|
69
|
+
|
70
|
+
==== RubyGems
|
71
|
+
|
72
|
+
Download and extract the zip file from the {RubyGems download page}[https://rubygems.org/pages/download].
|
73
|
+
|
74
|
+
Then run the following:
|
75
|
+
|
76
|
+
$ cd <path/to/extracted/zip>
|
77
|
+
$ ruby setup.rb
|
78
|
+
|
79
|
+
=== Linux
|
80
|
+
|
81
|
+
==== Ruby
|
82
|
+
|
83
|
+
Run the following:
|
84
|
+
|
85
|
+
$ sudo apt install ruby-full
|
86
|
+
|
87
|
+
==== RubyGems
|
88
|
+
|
89
|
+
Download and extract the zip file from the {RubyGems download page}[https://rubygems.org/pages/download].
|
90
|
+
|
91
|
+
Then run the following:
|
92
|
+
|
93
|
+
$ cd <path/to/extracted/zip>
|
94
|
+
$ ruby setup.rb
|
data/Rakefile
ADDED
@@ -0,0 +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_files.include('README.rdoc', 'lib/*.rb', 'lib/**/*.rb', 'test/*.rb', 'bin/*')
|
16
|
+
rdoc.rdoc_dir = 'doc'
|
17
|
+
end
|
18
|
+
|
19
|
+
# for Windows
|
20
|
+
task :deldoc do
|
21
|
+
`RMDIR /S /Q "doc"`
|
22
|
+
end
|
23
|
+
|
24
|
+
# for Unix
|
25
|
+
task :deldocx do
|
26
|
+
`rm -rf doc`
|
27
|
+
end
|
@@ -0,0 +1,13 @@
|
|
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(PhoneNumberValidator.validate_phone_number(ARGV[0]))
|
@@ -0,0 +1,164 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>class PhoneNumberValidator - 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-validate_phone_number">::validate_phone_number</a>
|
74
|
+
|
75
|
+
</ul>
|
76
|
+
</div>
|
77
|
+
|
78
|
+
</div>
|
79
|
+
</nav>
|
80
|
+
|
81
|
+
<main role="main" aria-labelledby="class-PhoneNumberValidator">
|
82
|
+
<h1 id="class-PhoneNumberValidator" class="class">
|
83
|
+
class PhoneNumberValidator
|
84
|
+
</h1>
|
85
|
+
|
86
|
+
<section class="description">
|
87
|
+
|
88
|
+
</section>
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
104
|
+
<header>
|
105
|
+
<h3>Public Class Methods</h3>
|
106
|
+
</header>
|
107
|
+
|
108
|
+
|
109
|
+
<div id="method-c-validate_phone_number" class="method-detail ">
|
110
|
+
|
111
|
+
<div class="method-heading">
|
112
|
+
<span class="method-name">validate_phone_number</span><span
|
113
|
+
class="method-args">(phone_number)</span>
|
114
|
+
|
115
|
+
<span class="method-click-advice">click to toggle source</span>
|
116
|
+
|
117
|
+
</div>
|
118
|
+
|
119
|
+
|
120
|
+
<div class="method-description">
|
121
|
+
|
122
|
+
<p>Validate any United States phone mumber!</p>
|
123
|
+
|
124
|
+
<p>Example:</p>
|
125
|
+
|
126
|
+
<pre>>> PhoneNumberValidator.validate_phone_number('+1 (949) 355-6244 ext. 198842')
|
127
|
+
=> '+1 (949) 355-6244 ext. 198842' is a valid phone number.'
|
128
|
+
=> true</pre>
|
129
|
+
|
130
|
+
<p>Arguments:</p>
|
131
|
+
|
132
|
+
<pre>phone_no: (String)</pre>
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
<div class="method-source-code" id="validate_phone_number-source">
|
138
|
+
<pre><span class="ruby-comment"># File lib/phone_number_validator.rb, line 12</span>
|
139
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">validate_phone_number</span>(<span class="ruby-identifier">phone_number</span>)
|
140
|
+
<span class="ruby-identifier">validator</span> = <span class="ruby-constant">Validator</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">phone_number</span>)
|
141
|
+
<span class="ruby-identifier">validator</span>.<span class="ruby-identifier">validate_phone_number</span>
|
142
|
+
<span class="ruby-keyword">end</span></pre>
|
143
|
+
</div>
|
144
|
+
|
145
|
+
</div>
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
</div>
|
151
|
+
|
152
|
+
|
153
|
+
</section>
|
154
|
+
|
155
|
+
</section>
|
156
|
+
</main>
|
157
|
+
|
158
|
+
|
159
|
+
<footer id="validator-badges" role="contentinfo">
|
160
|
+
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
161
|
+
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.1.
|
162
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
163
|
+
</footer>
|
164
|
+
|
@@ -0,0 +1,216 @@
|
|
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
|
+
</section>
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
<section class="constants-list">
|
102
|
+
<header>
|
103
|
+
<h3>Constants</h3>
|
104
|
+
</header>
|
105
|
+
<dl>
|
106
|
+
|
107
|
+
<dt id="PHONE_NUMBER_REGEX">PHONE_NUMBER_REGEX
|
108
|
+
|
109
|
+
<dd>
|
110
|
+
|
111
|
+
|
112
|
+
</dl>
|
113
|
+
</section>
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
120
|
+
<header>
|
121
|
+
<h3>Public Class Methods</h3>
|
122
|
+
</header>
|
123
|
+
|
124
|
+
|
125
|
+
<div id="method-c-new" class="method-detail ">
|
126
|
+
|
127
|
+
<div class="method-heading">
|
128
|
+
<span class="method-name">new</span><span
|
129
|
+
class="method-args">(phone_number = '+1 (949) 355-6244 ext. 198842')</span>
|
130
|
+
|
131
|
+
<span class="method-click-advice">click to toggle source</span>
|
132
|
+
|
133
|
+
</div>
|
134
|
+
|
135
|
+
|
136
|
+
<div class="method-description">
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
<div class="method-source-code" id="new-source">
|
144
|
+
<pre><span class="ruby-comment"># File lib/phone_number_validator/validator.rb, line 3</span>
|
145
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">phone_number</span> = <span class="ruby-string">'+1 (949) 355-6244 ext. 198842'</span>)
|
146
|
+
<span class="ruby-ivar">@phone_number</span> = <span class="ruby-identifier">phone_number</span>
|
147
|
+
<span class="ruby-keyword">end</span></pre>
|
148
|
+
</div>
|
149
|
+
|
150
|
+
</div>
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
</div>
|
156
|
+
|
157
|
+
|
158
|
+
</section>
|
159
|
+
|
160
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
161
|
+
<header>
|
162
|
+
<h3>Public Instance Methods</h3>
|
163
|
+
</header>
|
164
|
+
|
165
|
+
|
166
|
+
<div id="method-i-validate_phone_number" class="method-detail ">
|
167
|
+
|
168
|
+
<div class="method-heading">
|
169
|
+
<span class="method-name">validate_phone_number</span><span
|
170
|
+
class="method-args">()</span>
|
171
|
+
|
172
|
+
<span class="method-click-advice">click to toggle source</span>
|
173
|
+
|
174
|
+
</div>
|
175
|
+
|
176
|
+
|
177
|
+
<div class="method-description">
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
<div class="method-source-code" id="validate_phone_number-source">
|
185
|
+
<pre><span class="ruby-comment"># File lib/phone_number_validator/validator.rb, line 6</span>
|
186
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">validate_phone_number</span>
|
187
|
+
<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>))
|
188
|
+
<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>
|
189
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span>
|
190
|
+
<span class="ruby-keyword">else</span>
|
191
|
+
<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>
|
192
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span>
|
193
|
+
<span class="ruby-keyword">end</span>
|
194
|
+
<span class="ruby-keyword">end</span></pre>
|
195
|
+
</div>
|
196
|
+
|
197
|
+
</div>
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
</div>
|
203
|
+
|
204
|
+
|
205
|
+
</section>
|
206
|
+
|
207
|
+
</section>
|
208
|
+
</main>
|
209
|
+
|
210
|
+
|
211
|
+
<footer id="validator-badges" role="contentinfo">
|
212
|
+
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
213
|
+
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.1.
|
214
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
215
|
+
</footer>
|
216
|
+
|