qo 0.2.0 → 0.2.1
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 +5 -5
- data/.yardopts +3 -0
- data/README.md +35 -2
- data/Rakefile +65 -13
- data/docs/Qo.html +165 -0
- data/docs/Qo/Exceptions.html +160 -0
- data/docs/Qo/Exceptions/MultipleMatchersProvided.html +257 -0
- data/docs/Qo/Exceptions/NoMatchersProvided.html +257 -0
- data/docs/Qo/Exceptions/NotAllGuardMatchersProvided.html +260 -0
- data/docs/Qo/Helpers.html +382 -0
- data/docs/Qo/Matchers.html +169 -0
- data/docs/Qo/Matchers/ArrayMatcher.html +459 -0
- data/docs/Qo/Matchers/BaseMatcher.html +493 -0
- data/docs/Qo/Matchers/GuardBlockMatcher.html +471 -0
- data/docs/Qo/Matchers/HashMatcher.html +445 -0
- data/docs/Qo/Matchers/PatternMatch.html +551 -0
- data/docs/Qo/PublicApi.html +867 -0
- data/docs/_index.html +258 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +499 -0
- data/docs/file.README.html +701 -0
- data/docs/file_list.html +56 -0
- data/docs/frames.html +17 -0
- data/docs/img/qo_logo.png +0 -0
- data/docs/index.html +701 -0
- data/docs/js/app.js +248 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +227 -0
- data/docs/top-level-namespace.html +110 -0
- data/img/whoa_lemur.png +0 -0
- data/lib/qo/exceptions.rb +8 -4
- data/lib/qo/matchers/array_matcher.rb +34 -12
- data/lib/qo/matchers/base_matcher.rb +26 -11
- data/lib/qo/matchers/guard_block_matcher.rb +17 -3
- data/lib/qo/matchers/hash_matcher.rb +32 -23
- data/lib/qo/matchers/pattern_match.rb +2 -1
- data/lib/qo/public_api.rb +6 -5
- data/lib/qo/version.rb +1 -1
- data/performance_report.txt +73 -24
- data/qo.gemspec +2 -0
- metadata +61 -3
@@ -0,0 +1,169 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Module: Qo::Matchers
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.12
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "Qo::Matchers";
|
19
|
+
relpath = '../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../_index.html">Index (M)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../Qo.html" title="Qo (module)">Qo</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">Matchers</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Module: Qo::Matchers
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<dl>
|
80
|
+
<dt>Defined in:</dt>
|
81
|
+
<dd>lib/qo/matchers/base_matcher.rb<span class="defines">,<br />
|
82
|
+
lib/qo/matchers/hash_matcher.rb,<br /> lib/qo/matchers/array_matcher.rb,<br /> lib/qo/matchers/pattern_match.rb,<br /> lib/qo/matchers/guard_block_matcher.rb</span>
|
83
|
+
</dd>
|
84
|
+
</dl>
|
85
|
+
|
86
|
+
</div>
|
87
|
+
|
88
|
+
<h2>Overview</h2><div class="docstring">
|
89
|
+
<div class="discussion">
|
90
|
+
<p>A Qo Matcher is a class that acts like a Proc. It takes in a set of match
|
91
|
+
values or key value pairs and a target value to evaluate against, and returns
|
92
|
+
the status of that match.</p>
|
93
|
+
|
94
|
+
<p>It is possible to override this behavior via <code>to_proc</code> overloading and
|
95
|
+
utilization of <code>super</code> as noted in <code>GuardBlockMatcher</code>.</p>
|
96
|
+
|
97
|
+
|
98
|
+
</div>
|
99
|
+
</div>
|
100
|
+
<div class="tags">
|
101
|
+
|
102
|
+
|
103
|
+
<p class="tag_title">See Also:</p>
|
104
|
+
<ul class="see">
|
105
|
+
|
106
|
+
<li><span class='object_link'><a href="Matchers/GuardBlockMatcher.html" title="Qo::Matchers::GuardBlockMatcher (class)">GuardBlockMatcher</a></span></li>
|
107
|
+
|
108
|
+
</ul>
|
109
|
+
<p class="tag_title">Author:</p>
|
110
|
+
<ul class="author">
|
111
|
+
|
112
|
+
<li>
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
<div class='inline'><p>baweaver</p>
|
119
|
+
</div>
|
120
|
+
|
121
|
+
</li>
|
122
|
+
|
123
|
+
</ul>
|
124
|
+
<p class="tag_title">Since:</p>
|
125
|
+
<ul class="since">
|
126
|
+
|
127
|
+
<li>
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
<div class='inline'><p>0.2.0</p>
|
134
|
+
</div>
|
135
|
+
|
136
|
+
</li>
|
137
|
+
|
138
|
+
</ul>
|
139
|
+
|
140
|
+
</div><h2>Defined Under Namespace</h2>
|
141
|
+
<p class="children">
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Matchers/ArrayMatcher.html" title="Qo::Matchers::ArrayMatcher (class)">ArrayMatcher</a></span>, <span class='object_link'><a href="Matchers/BaseMatcher.html" title="Qo::Matchers::BaseMatcher (class)">BaseMatcher</a></span>, <span class='object_link'><a href="Matchers/GuardBlockMatcher.html" title="Qo::Matchers::GuardBlockMatcher (class)">GuardBlockMatcher</a></span>, <span class='object_link'><a href="Matchers/HashMatcher.html" title="Qo::Matchers::HashMatcher (class)">HashMatcher</a></span>, <span class='object_link'><a href="Matchers/PatternMatch.html" title="Qo::Matchers::PatternMatch (class)">PatternMatch</a></span>
|
147
|
+
|
148
|
+
|
149
|
+
</p>
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
</div>
|
160
|
+
|
161
|
+
<div id="footer">
|
162
|
+
Generated on Sun Apr 15 20:29:44 2018 by
|
163
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
164
|
+
0.9.12 (ruby-2.4.4).
|
165
|
+
</div>
|
166
|
+
|
167
|
+
</div>
|
168
|
+
</body>
|
169
|
+
</html>
|
@@ -0,0 +1,459 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Class: Qo::Matchers::ArrayMatcher
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.12
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "Qo::Matchers::ArrayMatcher";
|
19
|
+
relpath = '../../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../../_index.html">Index (A)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../../Qo.html" title="Qo (module)">Qo</a></span></span> » <span class='title'><span class='object_link'><a href="../Matchers.html" title="Qo::Matchers (module)">Matchers</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">ArrayMatcher</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Class: Qo::Matchers::ArrayMatcher
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
<dl>
|
70
|
+
<dt>Inherits:</dt>
|
71
|
+
<dd>
|
72
|
+
<span class="inheritName"><span class='object_link'><a href="BaseMatcher.html" title="Qo::Matchers::BaseMatcher (class)">BaseMatcher</a></span></span>
|
73
|
+
|
74
|
+
<ul class="fullTree">
|
75
|
+
<li>Object</li>
|
76
|
+
|
77
|
+
<li class="next"><span class='object_link'><a href="BaseMatcher.html" title="Qo::Matchers::BaseMatcher (class)">BaseMatcher</a></span></li>
|
78
|
+
|
79
|
+
<li class="next">Qo::Matchers::ArrayMatcher</li>
|
80
|
+
|
81
|
+
</ul>
|
82
|
+
<a href="#" class="inheritanceTree">show all</a>
|
83
|
+
|
84
|
+
</dd>
|
85
|
+
</dl>
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
<dl>
|
98
|
+
<dt>Defined in:</dt>
|
99
|
+
<dd>lib/qo/matchers/array_matcher.rb</dd>
|
100
|
+
</dl>
|
101
|
+
|
102
|
+
</div>
|
103
|
+
|
104
|
+
<h2>Overview</h2><div class="docstring">
|
105
|
+
<div class="discussion">
|
106
|
+
<p>An Array Matcher is a matcher that uses only <code>*varargs</code> to define a sequence
|
107
|
+
of matches to perform against either an object or another Array.</p>
|
108
|
+
|
109
|
+
<p>In the case of an Array matching against an Array it will compare via index.</p>
|
110
|
+
|
111
|
+
<pre class="code ruby"><code class="ruby"><span class='comment'># Shorthand
|
112
|
+
</span><span class='const'><span class='object_link'><a href="../../Qo.html" title="Qo (module)">Qo</a></span></span><span class='lbracket'>[</span><span class='int'>1</span><span class='op'>..</span><span class='int'>10</span><span class='comma'>,</span> <span class='int'>1</span><span class='op'>..</span><span class='int'>10</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>2</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
113
|
+
<span class='comment'># => true
|
114
|
+
</span>
|
115
|
+
<span class='const'><span class='object_link'><a href="../../Qo.html" title="Qo (module)">Qo</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Matchers.html" title="Qo::Matchers (module)">Matchers</a></span></span><span class='op'>::</span><span class='const'>ArrayMatcher</span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="BaseMatcher.html#initialize-instance_method" title="Qo::Matchers::BaseMatcher#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='int'>1</span><span class='op'>..</span><span class='int'>10</span><span class='comma'>,</span> <span class='int'>1</span><span class='op'>..</span><span class='int'>10</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_call'><span class='object_link'><a href="BaseMatcher.html#call-instance_method" title="Qo::Matchers::BaseMatcher#call (method)">call</a></span></span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>2</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
116
|
+
<span class='comment'># => true
|
117
|
+
</span></code></pre>
|
118
|
+
|
119
|
+
<p>In the case of an Array matching against an Object, it will match each provided
|
120
|
+
matcher against the object.</p>
|
121
|
+
|
122
|
+
<pre class="code ruby"><code class="ruby"><span class='comment'># Shorthand
|
123
|
+
</span><span class='const'><span class='object_link'><a href="../../Qo.html" title="Qo (module)">Qo</a></span></span><span class='lbracket'>[</span><span class='const'>Integer</span><span class='comma'>,</span> <span class='int'>1</span><span class='op'>..</span><span class='int'>10</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span>
|
124
|
+
<span class='comment'># => true
|
125
|
+
</span>
|
126
|
+
<span class='const'><span class='object_link'><a href="../../Qo.html" title="Qo (module)">Qo</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Matchers.html" title="Qo::Matchers (module)">Matchers</a></span></span><span class='op'>::</span><span class='const'>ArrayMatcher</span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="BaseMatcher.html#initialize-instance_method" title="Qo::Matchers::BaseMatcher#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='int'>1</span><span class='op'>..</span><span class='int'>10</span><span class='comma'>,</span> <span class='int'>1</span><span class='op'>..</span><span class='int'>10</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_call'><span class='object_link'><a href="BaseMatcher.html#call-instance_method" title="Qo::Matchers::BaseMatcher#call (method)">call</a></span></span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span>
|
127
|
+
<span class='comment'># => true
|
128
|
+
</span></code></pre>
|
129
|
+
|
130
|
+
<p>All variants present in the BaseMatcher are present here, including 'and',
|
131
|
+
'not', and 'or'.</p>
|
132
|
+
|
133
|
+
|
134
|
+
</div>
|
135
|
+
</div>
|
136
|
+
<div class="tags">
|
137
|
+
|
138
|
+
<p class="tag_title">Author:</p>
|
139
|
+
<ul class="author">
|
140
|
+
|
141
|
+
<li>
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
<div class='inline'><p>baweaver</p>
|
148
|
+
</div>
|
149
|
+
|
150
|
+
</li>
|
151
|
+
|
152
|
+
</ul>
|
153
|
+
<p class="tag_title">Since:</p>
|
154
|
+
<ul class="since">
|
155
|
+
|
156
|
+
<li>
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
<div class='inline'><p>0.2.0</p>
|
163
|
+
</div>
|
164
|
+
|
165
|
+
</li>
|
166
|
+
|
167
|
+
</ul>
|
168
|
+
|
169
|
+
</div>
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
<h2>
|
178
|
+
Instance Method Summary
|
179
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
180
|
+
</h2>
|
181
|
+
|
182
|
+
<ul class="summary">
|
183
|
+
|
184
|
+
<li class="public ">
|
185
|
+
<span class="summary_signature">
|
186
|
+
|
187
|
+
<a href="#call-instance_method" title="#call (instance method)">#<strong>call</strong>(target) ⇒ Boolean </a>
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
</span>
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
<span class="summary_desc"><div class='inline'><p>Runs the matcher directly.</p>
|
202
|
+
</div></span>
|
203
|
+
|
204
|
+
</li>
|
205
|
+
|
206
|
+
|
207
|
+
<li class="public ">
|
208
|
+
<span class="summary_signature">
|
209
|
+
|
210
|
+
<a href="#to_proc-instance_method" title="#to_proc (instance method)">#<strong>to_proc</strong> ⇒ Proc[Any] </a>
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
</span>
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
<span class="summary_desc"><div class='inline'><p>Wrapper around call to allow for invocation in an Enumerable function, such as:.</p>
|
225
|
+
</div></span>
|
226
|
+
|
227
|
+
</li>
|
228
|
+
|
229
|
+
|
230
|
+
</ul>
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
|
242
|
+
<h3 class="inherited">Methods inherited from <span class='object_link'><a href="BaseMatcher.html" title="Qo::Matchers::BaseMatcher (class)">BaseMatcher</a></span></h3>
|
243
|
+
<p class="inherited"><span class='object_link'><a href="BaseMatcher.html#initialize-instance_method" title="Qo::Matchers::BaseMatcher#initialize (method)">#initialize</a></span></p>
|
244
|
+
<div id="constructor_details" class="method_details_list">
|
245
|
+
<h2>Constructor Details</h2>
|
246
|
+
|
247
|
+
<p class="notice">This class inherits a constructor from <span class='object_link'><a href="BaseMatcher.html#initialize-instance_method" title="Qo::Matchers::BaseMatcher#initialize (method)">Qo::Matchers::BaseMatcher</a></span></p>
|
248
|
+
|
249
|
+
</div>
|
250
|
+
|
251
|
+
|
252
|
+
<div id="instance_method_details" class="method_details_list">
|
253
|
+
<h2>Instance Method Details</h2>
|
254
|
+
|
255
|
+
|
256
|
+
<div class="method_details first">
|
257
|
+
<h3 class="signature first" id="call-instance_method">
|
258
|
+
|
259
|
+
#<strong>call</strong>(target) ⇒ <tt>Boolean</tt>
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
</h3><div class="docstring">
|
266
|
+
<div class="discussion">
|
267
|
+
<p>Runs the matcher directly.</p>
|
268
|
+
|
269
|
+
<p>If the target is an Array, it will be matched via index</p>
|
270
|
+
|
271
|
+
<p>If the target is an Object, it will be matched via public send</p>
|
272
|
+
|
273
|
+
|
274
|
+
</div>
|
275
|
+
</div>
|
276
|
+
<div class="tags">
|
277
|
+
<p class="tag_title">Parameters:</p>
|
278
|
+
<ul class="param">
|
279
|
+
|
280
|
+
<li>
|
281
|
+
|
282
|
+
<span class='name'>target</span>
|
283
|
+
|
284
|
+
|
285
|
+
<span class='type'>(<tt>Any</tt>)</span>
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
—
|
290
|
+
<div class='inline'><p>Target to match against</p>
|
291
|
+
</div>
|
292
|
+
|
293
|
+
</li>
|
294
|
+
|
295
|
+
</ul>
|
296
|
+
|
297
|
+
<p class="tag_title">Returns:</p>
|
298
|
+
<ul class="return">
|
299
|
+
|
300
|
+
<li>
|
301
|
+
|
302
|
+
|
303
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
—
|
308
|
+
<div class='inline'><p>Result of the match</p>
|
309
|
+
</div>
|
310
|
+
|
311
|
+
</li>
|
312
|
+
|
313
|
+
</ul>
|
314
|
+
<p class="tag_title">Since:</p>
|
315
|
+
<ul class="since">
|
316
|
+
|
317
|
+
<li>
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
<div class='inline'><p>0.2.0</p>
|
324
|
+
</div>
|
325
|
+
|
326
|
+
</li>
|
327
|
+
|
328
|
+
</ul>
|
329
|
+
|
330
|
+
</div><table class="source_code">
|
331
|
+
<tr>
|
332
|
+
<td>
|
333
|
+
<pre class="lines">
|
334
|
+
|
335
|
+
|
336
|
+
58
|
337
|
+
59
|
338
|
+
60
|
339
|
+
61
|
340
|
+
62
|
341
|
+
63
|
342
|
+
64
|
343
|
+
65
|
344
|
+
66
|
345
|
+
67
|
346
|
+
68
|
347
|
+
69
|
348
|
+
70</pre>
|
349
|
+
</td>
|
350
|
+
<td>
|
351
|
+
<pre class="code"><span class="info file"># File 'lib/qo/matchers/array_matcher.rb', line 58</span>
|
352
|
+
|
353
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='rparen'>)</span>
|
354
|
+
<span class='kw'>return</span> <span class='kw'>true</span> <span class='kw'>if</span> <span class='ivar'>@array_matchers</span> <span class='op'>==</span> <span class='id identifier rubyid_target'>target</span>
|
355
|
+
|
356
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_target'>target</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Array</span><span class='rparen'>)</span>
|
357
|
+
<span class='id identifier rubyid_match_with'>match_with</span><span class='lparen'>(</span><span class='ivar'>@array_matchers</span><span class='period'>.</span><span class='id identifier rubyid_each_with_index'>each_with_index</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_matcher'>matcher</span><span class='comma'>,</span> <span class='id identifier rubyid_i'>i</span><span class='op'>|</span>
|
358
|
+
<span class='id identifier rubyid_match_value?'>match_value?</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='lbracket'>[</span><span class='id identifier rubyid_i'>i</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_matcher'>matcher</span><span class='rparen'>)</span>
|
359
|
+
<span class='rbrace'>}</span>
|
360
|
+
<span class='kw'>else</span>
|
361
|
+
<span class='id identifier rubyid_match_with'>match_with</span><span class='lparen'>(</span><span class='ivar'>@array_matchers</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_matcher'>matcher</span><span class='op'>|</span>
|
362
|
+
<span class='id identifier rubyid_match_value?'>match_value?</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_matcher'>matcher</span><span class='rparen'>)</span>
|
363
|
+
<span class='rbrace'>}</span>
|
364
|
+
<span class='kw'>end</span>
|
365
|
+
<span class='kw'>end</span></pre>
|
366
|
+
</td>
|
367
|
+
</tr>
|
368
|
+
</table>
|
369
|
+
</div>
|
370
|
+
|
371
|
+
<div class="method_details ">
|
372
|
+
<h3 class="signature " id="to_proc-instance_method">
|
373
|
+
|
374
|
+
#<strong>to_proc</strong> ⇒ <tt>Proc[Any]</tt>
|
375
|
+
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
|
380
|
+
</h3><div class="docstring">
|
381
|
+
<div class="discussion">
|
382
|
+
<p>Wrapper around call to allow for invocation in an Enumerable function,
|
383
|
+
such as:</p>
|
384
|
+
|
385
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_people'>people</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span><span class='lparen'>(</span><span class='op'>&</span><span class='const'><span class='object_link'><a href="../../Qo.html" title="Qo (module)">Qo</a></span></span><span class='lbracket'>[</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>Foo</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='int'>20</span><span class='op'>..</span><span class='int'>40</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
386
|
+
</code></pre>
|
387
|
+
|
388
|
+
|
389
|
+
</div>
|
390
|
+
</div>
|
391
|
+
<div class="tags">
|
392
|
+
|
393
|
+
<p class="tag_title">Returns:</p>
|
394
|
+
<ul class="return">
|
395
|
+
|
396
|
+
<li>
|
397
|
+
|
398
|
+
|
399
|
+
<span class='type'>(<tt>Proc[Any]</tt>)</span>
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
—
|
404
|
+
<div class='inline'><p>Proc awaiting a target to match against</p>
|
405
|
+
</div>
|
406
|
+
|
407
|
+
</li>
|
408
|
+
|
409
|
+
</ul>
|
410
|
+
<p class="tag_title">Since:</p>
|
411
|
+
<ul class="since">
|
412
|
+
|
413
|
+
<li>
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
<div class='inline'><p>0.2.0</p>
|
420
|
+
</div>
|
421
|
+
|
422
|
+
</li>
|
423
|
+
|
424
|
+
</ul>
|
425
|
+
|
426
|
+
</div><table class="source_code">
|
427
|
+
<tr>
|
428
|
+
<td>
|
429
|
+
<pre class="lines">
|
430
|
+
|
431
|
+
|
432
|
+
45
|
433
|
+
46
|
434
|
+
47</pre>
|
435
|
+
</td>
|
436
|
+
<td>
|
437
|
+
<pre class="code"><span class="info file"># File 'lib/qo/matchers/array_matcher.rb', line 45</span>
|
438
|
+
|
439
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_to_proc'>to_proc</span>
|
440
|
+
<span class='const'>Proc</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_target'>target</span><span class='op'>|</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
441
|
+
<span class='kw'>end</span></pre>
|
442
|
+
</td>
|
443
|
+
</tr>
|
444
|
+
</table>
|
445
|
+
</div>
|
446
|
+
|
447
|
+
</div>
|
448
|
+
|
449
|
+
</div>
|
450
|
+
|
451
|
+
<div id="footer">
|
452
|
+
Generated on Sun Apr 15 20:29:44 2018 by
|
453
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
454
|
+
0.9.12 (ruby-2.4.4).
|
455
|
+
</div>
|
456
|
+
|
457
|
+
</div>
|
458
|
+
</body>
|
459
|
+
</html>
|