qo 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +5 -5
  2. data/.yardopts +3 -0
  3. data/README.md +35 -2
  4. data/Rakefile +65 -13
  5. data/docs/Qo.html +165 -0
  6. data/docs/Qo/Exceptions.html +160 -0
  7. data/docs/Qo/Exceptions/MultipleMatchersProvided.html +257 -0
  8. data/docs/Qo/Exceptions/NoMatchersProvided.html +257 -0
  9. data/docs/Qo/Exceptions/NotAllGuardMatchersProvided.html +260 -0
  10. data/docs/Qo/Helpers.html +382 -0
  11. data/docs/Qo/Matchers.html +169 -0
  12. data/docs/Qo/Matchers/ArrayMatcher.html +459 -0
  13. data/docs/Qo/Matchers/BaseMatcher.html +493 -0
  14. data/docs/Qo/Matchers/GuardBlockMatcher.html +471 -0
  15. data/docs/Qo/Matchers/HashMatcher.html +445 -0
  16. data/docs/Qo/Matchers/PatternMatch.html +551 -0
  17. data/docs/Qo/PublicApi.html +867 -0
  18. data/docs/_index.html +258 -0
  19. data/docs/class_list.html +51 -0
  20. data/docs/css/common.css +1 -0
  21. data/docs/css/full_list.css +58 -0
  22. data/docs/css/style.css +499 -0
  23. data/docs/file.README.html +701 -0
  24. data/docs/file_list.html +56 -0
  25. data/docs/frames.html +17 -0
  26. data/docs/img/qo_logo.png +0 -0
  27. data/docs/index.html +701 -0
  28. data/docs/js/app.js +248 -0
  29. data/docs/js/full_list.js +216 -0
  30. data/docs/js/jquery.js +4 -0
  31. data/docs/method_list.html +227 -0
  32. data/docs/top-level-namespace.html +110 -0
  33. data/img/whoa_lemur.png +0 -0
  34. data/lib/qo/exceptions.rb +8 -4
  35. data/lib/qo/matchers/array_matcher.rb +34 -12
  36. data/lib/qo/matchers/base_matcher.rb +26 -11
  37. data/lib/qo/matchers/guard_block_matcher.rb +17 -3
  38. data/lib/qo/matchers/hash_matcher.rb +32 -23
  39. data/lib/qo/matchers/pattern_match.rb +2 -1
  40. data/lib/qo/public_api.rb +6 -5
  41. data/lib/qo/version.rb +1 -1
  42. data/performance_report.txt +73 -24
  43. data/qo.gemspec +2 -0
  44. metadata +61 -3
@@ -0,0 +1,445 @@
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::HashMatcher
8
+
9
+ &mdash; 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::HashMatcher";
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 (H)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../../Qo.html" title="Qo (module)">Qo</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Matchers.html" title="Qo::Matchers (module)">Matchers</a></span></span>
41
+ &raquo;
42
+ <span class="title">HashMatcher</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::HashMatcher
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::HashMatcher</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/hash_matcher.rb</dd>
100
+ </dl>
101
+
102
+ </div>
103
+
104
+ <h2>Overview</h2><div class="docstring">
105
+ <div class="discussion">
106
+ <p>A Hash Matcher is a matcher that uses only keyword args to define a sequence
107
+ of matches to perform against either an Object or another Hash.</p>
108
+
109
+ <p>In the case of a Hash matching against a Hash, it will compare the intersection
110
+ of keys and match the values against eachother.</p>
111
+
112
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="../../Qo.html" title="Qo (module)">Qo</a></span></span><span class='lbracket'>[</span><span class='label'>name:</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='label'>age:</span> <span class='int'>30</span><span class='op'>..</span><span class='int'>50</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='label'>name:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Foo</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>age:</span> <span class='int'>42</span><span class='rbrace'>}</span><span class='rparen'>)</span>
113
+ <span class='comment'># =&gt; true
114
+ </span></code></pre>
115
+
116
+ <p>In the case of a Hash matching against an Object, it will treat the keys as
117
+ method property invocations to be matched against the provided values.</p>
118
+
119
+ <h1>```ruby</h1>
120
+
121
+ <p>Qo[name: /Foo/, age: 30..50].call(Person.new(&#39;Foo&#39;, 42))</p>
122
+
123
+ <h1>=&gt; true</h1>
124
+
125
+ <pre class="code ruby"><code class="ruby">
126
+ All variants present in the BaseMatcher are present here, including &#39;and&#39;,
127
+ &#39;not&#39;, and &#39;or&#39;.
128
+ </code></pre>
129
+
130
+
131
+ </div>
132
+ </div>
133
+ <div class="tags">
134
+
135
+ <p class="tag_title">Author:</p>
136
+ <ul class="author">
137
+
138
+ <li>
139
+
140
+
141
+
142
+
143
+
144
+ <div class='inline'><p>baweaver</p>
145
+ </div>
146
+
147
+ </li>
148
+
149
+ </ul>
150
+ <p class="tag_title">Since:</p>
151
+ <ul class="since">
152
+
153
+ <li>
154
+
155
+
156
+
157
+
158
+
159
+ <div class='inline'><p>0.2.0</p>
160
+ </div>
161
+
162
+ </li>
163
+
164
+ </ul>
165
+
166
+ </div>
167
+
168
+
169
+
170
+
171
+
172
+
173
+
174
+ <h2>
175
+ Instance Method Summary
176
+ <small><a href="#" class="summary_toggle">collapse</a></small>
177
+ </h2>
178
+
179
+ <ul class="summary">
180
+
181
+ <li class="public ">
182
+ <span class="summary_signature">
183
+
184
+ <a href="#call-instance_method" title="#call (instance method)">#<strong>call</strong>(target) &#x21d2; Boolean </a>
185
+
186
+
187
+
188
+ </span>
189
+
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+ <span class="summary_desc"><div class='inline'><p>Used to match against a matcher made from Keyword Arguments (a Hash).</p>
199
+ </div></span>
200
+
201
+ </li>
202
+
203
+
204
+ <li class="public ">
205
+ <span class="summary_signature">
206
+
207
+ <a href="#to_proc-instance_method" title="#to_proc (instance method)">#<strong>to_proc</strong> &#x21d2; Proc[Any] </a>
208
+
209
+
210
+
211
+ </span>
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+
221
+ <span class="summary_desc"><div class='inline'><p>Wrapper around call to allow for invocation in an Enumerable function, such as:.</p>
222
+ </div></span>
223
+
224
+ </li>
225
+
226
+
227
+ </ul>
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+ <h3 class="inherited">Methods inherited from <span class='object_link'><a href="BaseMatcher.html" title="Qo::Matchers::BaseMatcher (class)">BaseMatcher</a></span></h3>
240
+ <p class="inherited"><span class='object_link'><a href="BaseMatcher.html#initialize-instance_method" title="Qo::Matchers::BaseMatcher#initialize (method)">#initialize</a></span></p>
241
+ <div id="constructor_details" class="method_details_list">
242
+ <h2>Constructor Details</h2>
243
+
244
+ <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>
245
+
246
+ </div>
247
+
248
+
249
+ <div id="instance_method_details" class="method_details_list">
250
+ <h2>Instance Method Details</h2>
251
+
252
+
253
+ <div class="method_details first">
254
+ <h3 class="signature first" id="call-instance_method">
255
+
256
+ #<strong>call</strong>(target) &#x21d2; <tt>Boolean</tt>
257
+
258
+
259
+
260
+
261
+
262
+ </h3><div class="docstring">
263
+ <div class="discussion">
264
+ <p>Used to match against a matcher made from Keyword Arguments (a Hash)</p>
265
+
266
+
267
+ </div>
268
+ </div>
269
+ <div class="tags">
270
+ <p class="tag_title">Parameters:</p>
271
+ <ul class="param">
272
+
273
+ <li>
274
+
275
+ <span class='name'>matchers</span>
276
+
277
+
278
+ <span class='type'>(<tt>Hash[Any, #===]</tt>)</span>
279
+
280
+
281
+
282
+ &mdash;
283
+ <div class='inline'><p>Any key mapping to any value that responds to <code>===</code>. Notedly more
284
+ satisfying when <code>===</code> does something fun.</p>
285
+ </div>
286
+
287
+ </li>
288
+
289
+ </ul>
290
+
291
+ <p class="tag_title">Returns:</p>
292
+ <ul class="return">
293
+
294
+ <li>
295
+
296
+
297
+ <span class='type'>(<tt>Boolean</tt>)</span>
298
+
299
+
300
+
301
+ &mdash;
302
+ <div class='inline'><p>Result of the match</p>
303
+ </div>
304
+
305
+ </li>
306
+
307
+ </ul>
308
+ <p class="tag_title">Since:</p>
309
+ <ul class="since">
310
+
311
+ <li>
312
+
313
+
314
+
315
+
316
+
317
+ <div class='inline'><p>0.2.0</p>
318
+ </div>
319
+
320
+ </li>
321
+
322
+ </ul>
323
+
324
+ </div><table class="source_code">
325
+ <tr>
326
+ <td>
327
+ <pre class="lines">
328
+
329
+
330
+ 49
331
+ 50
332
+ 51
333
+ 52
334
+ 53
335
+ 54
336
+ 55
337
+ 56
338
+ 57</pre>
339
+ </td>
340
+ <td>
341
+ <pre class="code"><span class="info file"># File 'lib/qo/matchers/hash_matcher.rb', line 49</span>
342
+
343
+ <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>
344
+ <span class='kw'>return</span> <span class='kw'>true</span> <span class='kw'>if</span> <span class='ivar'>@keyword_matchers</span> <span class='op'>==</span> <span class='id identifier rubyid_target'>target</span>
345
+
346
+ <span class='id identifier rubyid_match_fn'>match_fn</span> <span class='op'>=</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'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span>
347
+ <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_match_key'>match_key</span><span class='comma'>,</span> <span class='id identifier rubyid_matcher'>matcher</span><span class='op'>|</span> <span class='id identifier rubyid_match_hash_value?'>match_hash_value?</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_match_key'>match_key</span><span class='comma'>,</span> <span class='id identifier rubyid_matcher'>matcher</span><span class='rparen'>)</span> <span class='rbrace'>}</span> <span class='op'>:</span>
348
+ <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_match_key'>match_key</span><span class='comma'>,</span> <span class='id identifier rubyid_matcher'>matcher</span><span class='op'>|</span> <span class='id identifier rubyid_match_object_value?'>match_object_value?</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_match_key'>match_key</span><span class='comma'>,</span> <span class='id identifier rubyid_matcher'>matcher</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
349
+
350
+ <span class='id identifier rubyid_match_with'>match_with</span><span class='lparen'>(</span><span class='ivar'>@keyword_matchers</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_match_fn'>match_fn</span><span class='rparen'>)</span>
351
+ <span class='kw'>end</span></pre>
352
+ </td>
353
+ </tr>
354
+ </table>
355
+ </div>
356
+
357
+ <div class="method_details ">
358
+ <h3 class="signature " id="to_proc-instance_method">
359
+
360
+ #<strong>to_proc</strong> &#x21d2; <tt>Proc[Any]</tt>
361
+
362
+
363
+
364
+
365
+
366
+ </h3><div class="docstring">
367
+ <div class="discussion">
368
+ <p>Wrapper around call to allow for invocation in an Enumerable function,
369
+ such as:</p>
370
+
371
+ <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'>&amp;</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='label'>name:</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='label'>age:</span> <span class='int'>20</span><span class='op'>..</span><span class='int'>40</span><span class='rbracket'>]</span><span class='rparen'>)</span>
372
+ </code></pre>
373
+
374
+
375
+ </div>
376
+ </div>
377
+ <div class="tags">
378
+
379
+ <p class="tag_title">Returns:</p>
380
+ <ul class="return">
381
+
382
+ <li>
383
+
384
+
385
+ <span class='type'>(<tt>Proc[Any]</tt>)</span>
386
+
387
+
388
+
389
+ &mdash;
390
+ <div class='inline'><p>Proc awaiting a target to match against</p>
391
+ </div>
392
+
393
+ </li>
394
+
395
+ </ul>
396
+ <p class="tag_title">Since:</p>
397
+ <ul class="since">
398
+
399
+ <li>
400
+
401
+
402
+
403
+
404
+
405
+ <div class='inline'><p>0.2.0</p>
406
+ </div>
407
+
408
+ </li>
409
+
410
+ </ul>
411
+
412
+ </div><table class="source_code">
413
+ <tr>
414
+ <td>
415
+ <pre class="lines">
416
+
417
+
418
+ 38
419
+ 39
420
+ 40</pre>
421
+ </td>
422
+ <td>
423
+ <pre class="code"><span class="info file"># File 'lib/qo/matchers/hash_matcher.rb', line 38</span>
424
+
425
+ <span class='kw'>def</span> <span class='id identifier rubyid_to_proc'>to_proc</span>
426
+ <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>
427
+ <span class='kw'>end</span></pre>
428
+ </td>
429
+ </tr>
430
+ </table>
431
+ </div>
432
+
433
+ </div>
434
+
435
+ </div>
436
+
437
+ <div id="footer">
438
+ Generated on Sun Apr 15 20:29:44 2018 by
439
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
440
+ 0.9.12 (ruby-2.4.4).
441
+ </div>
442
+
443
+ </div>
444
+ </body>
445
+ </html>
@@ -0,0 +1,551 @@
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::PatternMatch
8
+
9
+ &mdash; 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::PatternMatch";
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 (P)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../../Qo.html" title="Qo (module)">Qo</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Matchers.html" title="Qo::Matchers (module)">Matchers</a></span></span>
41
+ &raquo;
42
+ <span class="title">PatternMatch</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::PatternMatch
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName">Object</span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">Qo::Matchers::PatternMatch</li>
78
+
79
+ </ul>
80
+ <a href="#" class="inheritanceTree">show all</a>
81
+
82
+ </dd>
83
+ </dl>
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+ <dl>
96
+ <dt>Defined in:</dt>
97
+ <dd>lib/qo/matchers/pattern_match.rb</dd>
98
+ </dl>
99
+
100
+ </div>
101
+
102
+ <h2>Overview</h2><div class="docstring">
103
+ <div class="discussion">
104
+ <p>Creates a PatternMatch, which will evaluate once given a match target.</p>
105
+
106
+ <p>Each GuardBlockMatcher given will be run in sequence until a &quot;match&quot; is
107
+ located. Once that condition is met, it will call the associated block
108
+ function of that GuardBlockMatcher with the match target.</p>
109
+
110
+ <p>This is done as an effort to emulate Right Hand Assignment seen in other
111
+ functionally oriented languages pattern matching systems. Most notably this
112
+ is done in Scala: (<a href="https://docs.scala-lang.org/tour/pattern-matching.html">https://docs.scala-lang.org/tour/pattern-matching.html</a>)</p>
113
+
114
+ <pre class="code scala"><code class="scala">notification match {
115
+ case Email(email, title, _) =&gt;
116
+ s&quot;You got an email from $email with title: $title&quot;
117
+
118
+ case SMS(number, message) =&gt;
119
+ s&quot;You got an SMS from $number! Message: $message&quot;
120
+
121
+ case VoiceRecording(name, link) =&gt;
122
+ s&quot;You received a Voice Recording from $name! Click the link to hear it: $link&quot;
123
+
124
+ case other =&gt; other
125
+ }
126
+ </code></pre>
127
+
128
+ <p>Qo will instead pipe the entire matched object, and might look something like this:</p>
129
+
130
+ <pre class="code ruby"><code class="ruby"><span class='comment'># Assuming notification is in the form of a tuple
131
+ </span>
132
+ <span class='const'><span class='object_link'><a href="../../Qo.html" title="Qo (module)">Qo</a></span></span><span class='period'>.</span><span class='id identifier rubyid_match'><span class='object_link'><a href="../PublicApi.html#match-instance_method" title="Qo::PublicApi#match (method)">match</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_notification'>notification</span><span class='comma'>,</span>
133
+ <span class='const'><span class='object_link'><a href="../../Qo.html" title="Qo (module)">Qo</a></span></span><span class='period'>.</span><span class='id identifier rubyid_m'>m</span><span class='lparen'>(</span><span class='const'>EMAIL_REGEX</span><span class='comma'>,</span> <span class='const'>String</span><span class='comma'>,</span> <span class='symbol'>:*</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_email'>email</span><span class='comma'>,</span> <span class='id identifier rubyid_title'>title</span><span class='comma'>,</span> <span class='id identifier rubyid__'>_</span><span class='op'>|</span>
134
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>You got an email from </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_email'>email</span><span class='embexpr_end'>}</span><span class='tstring_content'> with title: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_title'>title</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
135
+ <span class='rbrace'>}</span><span class='comma'>,</span>
136
+
137
+ <span class='const'><span class='object_link'><a href="../../Qo.html" title="Qo (module)">Qo</a></span></span><span class='period'>.</span><span class='id identifier rubyid_m'>m</span><span class='lparen'>(</span><span class='const'>PHONE_REGEX</span><span class='comma'>,</span> <span class='const'>String</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_number'>number</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='comma'>,</span> <span class='id identifier rubyid__'>_</span><span class='op'>|</span>
138
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>You got an SMS from </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_number'>number</span><span class='embexpr_end'>}</span><span class='tstring_content'>! Message: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_message'>message</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
139
+ <span class='rbrace'>}</span><span class='comma'>,</span>
140
+
141
+ <span class='const'><span class='object_link'><a href="../../Qo.html" title="Qo (module)">Qo</a></span></span><span class='period'>.</span><span class='id identifier rubyid_m'>m</span><span class='lparen'>(</span><span class='const'>String</span><span class='comma'>,</span> <span class='const'>LINK_REGEX</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_link'>link</span><span class='comma'>,</span> <span class='id identifier rubyid__'>_</span><span class='op'>|</span>
142
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>You received a Voice Recording from </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_content'>! Click the link to hear it: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_link'>link</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
143
+ <span class='rbrace'>}</span><span class='comma'>,</span>
144
+
145
+ <span class='const'><span class='object_link'><a href="../../Qo.html" title="Qo (module)">Qo</a></span></span><span class='period'>.</span><span class='id identifier rubyid_m'>m</span><span class='lparen'>(</span><span class='symbol'>:*</span><span class='rparen'>)</span>
146
+ <span class='rparen'>)</span>
147
+ </code></pre>
148
+
149
+ <p>Efforts to emulate the case class mechanic may be present in later versions,
150
+ but for now the associated performance penalty may be too steep to consider.</p>
151
+
152
+ <p>We&#39;ll evaluate those options in a few experiments later.</p>
153
+
154
+
155
+ </div>
156
+ </div>
157
+ <div class="tags">
158
+
159
+ <p class="tag_title">Author:</p>
160
+ <ul class="author">
161
+
162
+ <li>
163
+
164
+
165
+
166
+
167
+
168
+ <div class='inline'><p>baweaver</p>
169
+ </div>
170
+
171
+ </li>
172
+
173
+ </ul>
174
+ <p class="tag_title">Since:</p>
175
+ <ul class="since">
176
+
177
+ <li>
178
+
179
+
180
+
181
+
182
+
183
+ <div class='inline'><p>0.2.0</p>
184
+ </div>
185
+
186
+ </li>
187
+
188
+ </ul>
189
+
190
+ </div>
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+ <h2>
199
+ Instance Method Summary
200
+ <small><a href="#" class="summary_toggle">collapse</a></small>
201
+ </h2>
202
+
203
+ <ul class="summary">
204
+
205
+ <li class="public ">
206
+ <span class="summary_signature">
207
+
208
+ <a href="#call-instance_method" title="#call (instance method)">#<strong>call</strong>(target) &#x21d2; Any | nil </a>
209
+
210
+
211
+
212
+ </span>
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+
221
+
222
+ <span class="summary_desc"><div class='inline'><p>Immediately invokes a PatternMatch.</p>
223
+ </div></span>
224
+
225
+ </li>
226
+
227
+
228
+ <li class="public ">
229
+ <span class="summary_signature">
230
+
231
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(*matchers) &#x21d2; PatternMatch </a>
232
+
233
+
234
+
235
+ </span>
236
+
237
+
238
+ <span class="note title constructor">constructor</span>
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+ <span class="summary_desc"><div class='inline'><p>A new instance of PatternMatch.</p>
248
+ </div></span>
249
+
250
+ </li>
251
+
252
+
253
+ <li class="public ">
254
+ <span class="summary_signature">
255
+
256
+ <a href="#to_proc-instance_method" title="#to_proc (instance method)">#<strong>to_proc</strong> &#x21d2; Proc </a>
257
+
258
+
259
+
260
+ </span>
261
+
262
+
263
+
264
+
265
+
266
+
267
+
268
+
269
+
270
+ <span class="summary_desc"><div class='inline'><p>Function return of a PatternMatch waiting for a target to run.</p>
271
+ </div></span>
272
+
273
+ </li>
274
+
275
+
276
+ </ul>
277
+
278
+
279
+ <div id="constructor_details" class="method_details_list">
280
+ <h2>Constructor Details</h2>
281
+
282
+ <div class="method_details first">
283
+ <h3 class="signature first" id="initialize-instance_method">
284
+
285
+ #<strong>initialize</strong>(*matchers) &#x21d2; <tt><span class='object_link'><a href="" title="Qo::Matchers::PatternMatch (class)">PatternMatch</a></span></tt>
286
+
287
+
288
+
289
+
290
+
291
+ </h3><div class="docstring">
292
+ <div class="discussion">
293
+ <p>Returns a new instance of PatternMatch</p>
294
+
295
+
296
+ </div>
297
+ </div>
298
+ <div class="tags">
299
+
300
+ <p class="tag_title">Raises:</p>
301
+ <ul class="raise">
302
+
303
+ <li>
304
+
305
+
306
+ <span class='type'>(<tt><span class='object_link'><a href="../Exceptions/NotAllGuardMatchersProvided.html" title="Qo::Exceptions::NotAllGuardMatchersProvided (class)">Qo::Exceptions::NotAllGuardMatchersProvided</a></span></tt>)</span>
307
+
308
+
309
+
310
+ </li>
311
+
312
+ </ul>
313
+ <p class="tag_title">Since:</p>
314
+ <ul class="since">
315
+
316
+ <li>
317
+
318
+
319
+
320
+
321
+
322
+ <div class='inline'><p>0.2.0</p>
323
+ </div>
324
+
325
+ </li>
326
+
327
+ </ul>
328
+
329
+ </div><table class="source_code">
330
+ <tr>
331
+ <td>
332
+ <pre class="lines">
333
+
334
+
335
+ 61
336
+ 62
337
+ 63
338
+ 64
339
+ 65
340
+ 66
341
+ 67</pre>
342
+ </td>
343
+ <td>
344
+ <pre class="code"><span class="info file"># File 'lib/qo/matchers/pattern_match.rb', line 61</span>
345
+
346
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_matchers'>matchers</span><span class='rparen'>)</span>
347
+ <span class='id identifier rubyid_raise'>raise</span> <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="../Exceptions.html" title="Qo::Exceptions (module)">Exceptions</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Exceptions/NotAllGuardMatchersProvided.html" title="Qo::Exceptions::NotAllGuardMatchersProvided (class)">NotAllGuardMatchersProvided</a></span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_matchers'>matchers</span><span class='period'>.</span><span class='id identifier rubyid_all?'>all?</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_q'>q</span><span class='op'>|</span>
348
+ <span class='id identifier rubyid_q'>q</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><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'><span class='object_link'><a href="GuardBlockMatcher.html" title="Qo::Matchers::GuardBlockMatcher (class)">GuardBlockMatcher</a></span></span><span class='rparen'>)</span>
349
+ <span class='rbrace'>}</span>
350
+
351
+ <span class='ivar'>@matchers</span> <span class='op'>=</span> <span class='id identifier rubyid_matchers'>matchers</span>
352
+ <span class='kw'>end</span></pre>
353
+ </td>
354
+ </tr>
355
+ </table>
356
+ </div>
357
+
358
+ </div>
359
+
360
+
361
+ <div id="instance_method_details" class="method_details_list">
362
+ <h2>Instance Method Details</h2>
363
+
364
+
365
+ <div class="method_details first">
366
+ <h3 class="signature first" id="call-instance_method">
367
+
368
+ #<strong>call</strong>(target) &#x21d2; <tt>Any | nil</tt>
369
+
370
+
371
+
372
+
373
+
374
+ </h3><div class="docstring">
375
+ <div class="discussion">
376
+ <p>Immediately invokes a PatternMatch</p>
377
+
378
+
379
+ </div>
380
+ </div>
381
+ <div class="tags">
382
+ <p class="tag_title">Parameters:</p>
383
+ <ul class="param">
384
+
385
+ <li>
386
+
387
+ <span class='name'>target</span>
388
+
389
+
390
+ <span class='type'>(<tt>Any</tt>)</span>
391
+
392
+
393
+
394
+ &mdash;
395
+ <div class='inline'><p>Target to run against and pipe to the associated block if it
396
+ &quot;matches&quot; any of the GuardBlocks</p>
397
+ </div>
398
+
399
+ </li>
400
+
401
+ </ul>
402
+
403
+ <p class="tag_title">Returns:</p>
404
+ <ul class="return">
405
+
406
+ <li>
407
+
408
+
409
+ <span class='type'>(<tt>Any | nil</tt>)</span>
410
+
411
+
412
+
413
+ &mdash;
414
+ <div class='inline'><p>Result of the piped block, or nil on a miss</p>
415
+ </div>
416
+
417
+ </li>
418
+
419
+ </ul>
420
+ <p class="tag_title">Since:</p>
421
+ <ul class="since">
422
+
423
+ <li>
424
+
425
+
426
+
427
+
428
+
429
+ <div class='inline'><p>0.2.0</p>
430
+ </div>
431
+
432
+ </li>
433
+
434
+ </ul>
435
+
436
+ </div><table class="source_code">
437
+ <tr>
438
+ <td>
439
+ <pre class="lines">
440
+
441
+
442
+ 84
443
+ 85
444
+ 86
445
+ 87
446
+ 88
447
+ 89
448
+ 90
449
+ 91</pre>
450
+ </td>
451
+ <td>
452
+ <pre class="code"><span class="info file"># File 'lib/qo/matchers/pattern_match.rb', line 84</span>
453
+
454
+ <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>
455
+ <span class='ivar'>@matchers</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_guard_block_matcher'>guard_block_matcher</span><span class='op'>|</span>
456
+ <span class='id identifier rubyid_did_match'>did_match</span><span class='comma'>,</span> <span class='id identifier rubyid_match_result'>match_result</span> <span class='op'>=</span> <span class='id identifier rubyid_guard_block_matcher'>guard_block_matcher</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>
457
+ <span class='kw'>return</span> <span class='id identifier rubyid_match_result'>match_result</span> <span class='kw'>if</span> <span class='id identifier rubyid_did_match'>did_match</span>
458
+ <span class='rbrace'>}</span>
459
+
460
+ <span class='kw'>nil</span>
461
+ <span class='kw'>end</span></pre>
462
+ </td>
463
+ </tr>
464
+ </table>
465
+ </div>
466
+
467
+ <div class="method_details ">
468
+ <h3 class="signature " id="to_proc-instance_method">
469
+
470
+ #<strong>to_proc</strong> &#x21d2; <tt>Proc</tt>
471
+
472
+
473
+
474
+
475
+
476
+ </h3><div class="docstring">
477
+ <div class="discussion">
478
+ <p>Function return of a PatternMatch waiting for a target to run</p>
479
+
480
+
481
+ </div>
482
+ </div>
483
+ <div class="tags">
484
+
485
+ <p class="tag_title">Returns:</p>
486
+ <ul class="return">
487
+
488
+ <li>
489
+
490
+
491
+ <span class='type'>(<tt>Proc</tt>)</span>
492
+
493
+
494
+
495
+ &mdash;
496
+ <div class='inline'><p>Any -&gt; Any | nil</p>
497
+ </div>
498
+
499
+ </li>
500
+
501
+ </ul>
502
+ <p class="tag_title">Since:</p>
503
+ <ul class="since">
504
+
505
+ <li>
506
+
507
+
508
+
509
+
510
+
511
+ <div class='inline'><p>0.2.0</p>
512
+ </div>
513
+
514
+ </li>
515
+
516
+ </ul>
517
+
518
+ </div><table class="source_code">
519
+ <tr>
520
+ <td>
521
+ <pre class="lines">
522
+
523
+
524
+ 73
525
+ 74
526
+ 75</pre>
527
+ </td>
528
+ <td>
529
+ <pre class="code"><span class="info file"># File 'lib/qo/matchers/pattern_match.rb', line 73</span>
530
+
531
+ <span class='kw'>def</span> <span class='id identifier rubyid_to_proc'>to_proc</span>
532
+ <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>
533
+ <span class='kw'>end</span></pre>
534
+ </td>
535
+ </tr>
536
+ </table>
537
+ </div>
538
+
539
+ </div>
540
+
541
+ </div>
542
+
543
+ <div id="footer">
544
+ Generated on Sun Apr 15 20:29:44 2018 by
545
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
546
+ 0.9.12 (ruby-2.4.4).
547
+ </div>
548
+
549
+ </div>
550
+ </body>
551
+ </html>