qo 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -180,7 +180,7 @@ disappointment from the creator.</p>
180
180
  <li class="public ">
181
181
  <span class="summary_signature">
182
182
 
183
- <a href="#match-instance_method" title="#match (instance method)">#<strong>match</strong>(*args) &#x21d2; Qo::PatternMatch | Any </a>
183
+ <a href="#match-instance_method" title="#match (instance method)">#<strong>match</strong>(*args, &amp;fn) &#x21d2; Qo::PatternMatchBlock, ... </a>
184
184
 
185
185
 
186
186
 
@@ -391,7 +391,7 @@ a false match.</p>
391
391
  <pre class="code"><span class="info file"># File 'lib/qo/public_api.rb', line 23</span>
392
392
 
393
393
  <span class='kw'>def</span> <span class='kw'>and</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_array_matchers'>array_matchers</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_keyword_matchers'>keyword_matchers</span><span class='rparen'>)</span>
394
- <span class='id identifier rubyid_create_matcher'>create_matcher</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>and</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_array_matchers'>array_matchers</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_keyword_matchers'>keyword_matchers</span><span class='rparen'>)</span>
394
+ <span class='id identifier rubyid_create_matcher'>create_matcher</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>and</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_array_matchers'>array_matchers</span><span class='comma'>,</span> <span class='id identifier rubyid_keyword_matchers'>keyword_matchers</span><span class='rparen'>)</span>
395
395
  <span class='kw'>end</span></pre>
396
396
  </td>
397
397
  </tr>
@@ -401,7 +401,7 @@ a false match.</p>
401
401
  <div class="method_details ">
402
402
  <h3 class="signature " id="match-instance_method">
403
403
 
404
- #<strong>match</strong>(*args) &#x21d2; <tt>Qo::PatternMatch | Any</tt>
404
+ #<strong>match</strong>(*args, &amp;fn) &#x21d2; <tt>Qo::PatternMatchBlock</tt>, ...
405
405
 
406
406
 
407
407
 
@@ -423,6 +423,23 @@ associated matcher&#39;s block function.</p>
423
423
  <p class="tag_title">Parameters:</p>
424
424
  <ul class="param">
425
425
 
426
+ <li>
427
+
428
+ <span class='name'>fn</span>
429
+
430
+
431
+ <span class='type'>(<tt>Proc</tt>)</span>
432
+
433
+
434
+
435
+ &mdash;
436
+ <div class='inline'><p>If provided, the pattern match will become block-style, utilizing
437
+ PatternMatchBlock instead. If any args are provided, the first
438
+ will be treated as the target.</p>
439
+ </div>
440
+
441
+ </li>
442
+
426
443
  <li>
427
444
 
428
445
  <span class='name'>*args</span>
@@ -446,12 +463,41 @@ associated matcher&#39;s block function.</p>
446
463
  <li>
447
464
 
448
465
 
449
- <span class='type'>(<tt>Qo::PatternMatch | Any</tt>)</span>
466
+ <span class='type'>(<tt>Qo::PatternMatchBlock</tt>)</span>
450
467
 
451
468
 
452
469
 
453
470
  &mdash;
454
- <div class='inline'><p>Returns a PatternMatch waiting for a target, or an evaluated PatternMatch response</p>
471
+ <div class='inline'><p>If a value is not provided, a block style pattern match will be returned
472
+ that responds to proc coercion. It can be used for functions like <code>map</code>.</p>
473
+ </div>
474
+
475
+ </li>
476
+
477
+ <li>
478
+
479
+
480
+ <span class='type'>(<tt>Qo::PatternMatch</tt>)</span>
481
+
482
+
483
+
484
+ &mdash;
485
+ <div class='inline'><p>If a value is not provided and no function is present, a PatternMatch
486
+ will be returned, awaiting a value to match against.</p>
487
+ </div>
488
+
489
+ </li>
490
+
491
+ <li>
492
+
493
+
494
+ <span class='type'>(<tt>Any</tt>)</span>
495
+
496
+
497
+
498
+ &mdash;
499
+ <div class='inline'><p>If a value is provided, matchers will attempt to call through on it,
500
+ returning the result of the function.</p>
455
501
  </div>
456
502
 
457
503
  </li>
@@ -479,19 +525,31 @@ associated matcher&#39;s block function.</p>
479
525
  <pre class="lines">
480
526
 
481
527
 
482
- 90
483
- 91
484
- 92
485
- 93
486
- 94
487
- 95
488
- 96
489
- 97</pre>
528
+ 104
529
+ 105
530
+ 106
531
+ 107
532
+ 108
533
+ 109
534
+ 110
535
+ 111
536
+ 112
537
+ 113
538
+ 114
539
+ 115
540
+ 116
541
+ 117</pre>
490
542
  </td>
491
543
  <td>
492
- <pre class="code"><span class="info file"># File 'lib/qo/public_api.rb', line 90</span>
544
+ <pre class="code"><span class="info file"># File 'lib/qo/public_api.rb', line 104</span>
545
+
546
+ <span class='kw'>def</span> <span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_fn'>fn</span><span class='rparen'>)</span>
547
+ <span class='kw'>if</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
548
+ <span class='kw'>return</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span>
549
+ <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="Matchers/PatternMatchBlock.html" title="Qo::Matchers::PatternMatchBlock (class)">PatternMatchBlock</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Matchers/PatternMatchBlock.html#initialize-instance_method" title="Qo::Matchers::PatternMatchBlock#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_fn'>fn</span><span class='rparen'>)</span> <span class='op'>:</span>
550
+ <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="Matchers/PatternMatchBlock.html" title="Qo::Matchers::PatternMatchBlock (class)">PatternMatchBlock</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Matchers/PatternMatchBlock.html#initialize-instance_method" title="Qo::Matchers::PatternMatchBlock#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_fn'>fn</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_call'><span class='object_link'><a href="Matchers/PatternMatchBlock.html#call-instance_method" title="Qo::Matchers::PatternMatchBlock#call (method)">call</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='rparen'>)</span>
551
+ <span class='kw'>end</span>
493
552
 
494
- <span class='kw'>def</span> <span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
495
553
  <span class='kw'>if</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</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="Matchers/GuardBlockMatcher.html" title="Qo::Matchers::GuardBlockMatcher (class)">GuardBlockMatcher</a></span></span><span class='rparen'>)</span>
496
554
  <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="Matchers/PatternMatch.html" title="Qo::Matchers::PatternMatch (class)">PatternMatch</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Matchers/PatternMatch.html#initialize-instance_method" title="Qo::Matchers::PatternMatch#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
497
555
  <span class='kw'>else</span>
@@ -737,7 +795,7 @@ a true match.</p>
737
795
  <pre class="code"><span class="info file"># File 'lib/qo/public_api.rb', line 52</span>
738
796
 
739
797
  <span class='kw'>def</span> <span class='kw'>not</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_array_matchers'>array_matchers</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_keyword_matchers'>keyword_matchers</span><span class='rparen'>)</span>
740
- <span class='id identifier rubyid_create_matcher'>create_matcher</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>not</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_array_matchers'>array_matchers</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_keyword_matchers'>keyword_matchers</span><span class='rparen'>)</span>
798
+ <span class='id identifier rubyid_create_matcher'>create_matcher</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>not</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_array_matchers'>array_matchers</span><span class='comma'>,</span> <span class='id identifier rubyid_keyword_matchers'>keyword_matchers</span><span class='rparen'>)</span>
741
799
  <span class='kw'>end</span></pre>
742
800
  </td>
743
801
  </tr>
@@ -845,7 +903,7 @@ a true match.</p>
845
903
  <pre class="code"><span class="info file"># File 'lib/qo/public_api.rb', line 39</span>
846
904
 
847
905
  <span class='kw'>def</span> <span class='kw'>or</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_array_matchers'>array_matchers</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_keyword_matchers'>keyword_matchers</span><span class='rparen'>)</span>
848
- <span class='id identifier rubyid_create_matcher'>create_matcher</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>or</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_array_matchers'>array_matchers</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_keyword_matchers'>keyword_matchers</span><span class='rparen'>)</span>
906
+ <span class='id identifier rubyid_create_matcher'>create_matcher</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>or</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_array_matchers'>array_matchers</span><span class='comma'>,</span> <span class='id identifier rubyid_keyword_matchers'>keyword_matchers</span><span class='rparen'>)</span>
849
907
  <span class='kw'>end</span></pre>
850
908
  </td>
851
909
  </tr>
@@ -857,9 +915,9 @@ a true match.</p>
857
915
  </div>
858
916
 
859
917
  <div id="footer">
860
- Generated on Sun Apr 15 20:29:44 2018 by
918
+ Generated on Sun Aug 5 20:52:10 2018 by
861
919
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
862
- 0.9.12 (ruby-2.4.4).
920
+ 0.9.12 (ruby-2.5.1).
863
921
  </div>
864
922
 
865
923
  </div>
data/docs/_index.html CHANGED
@@ -169,6 +169,13 @@
169
169
 
170
170
  </li>
171
171
 
172
+ <li>
173
+ <span class='object_link'><a href="Qo/Exceptions/MultipleElseClauses.html" title="Qo::Exceptions::MultipleElseClauses (class)">MultipleElseClauses</a></span>
174
+
175
+ <small>(Qo::Exceptions)</small>
176
+
177
+ </li>
178
+
172
179
  <li>
173
180
  <span class='object_link'><a href="Qo/Exceptions/MultipleMatchersProvided.html" title="Qo::Exceptions::MultipleMatchersProvided (class)">MultipleMatchersProvided</a></span>
174
181
 
@@ -216,6 +223,13 @@
216
223
 
217
224
  </li>
218
225
 
226
+ <li>
227
+ <span class='object_link'><a href="Qo/Matchers/PatternMatchBlock.html" title="Qo::Matchers::PatternMatchBlock (class)">PatternMatchBlock</a></span>
228
+
229
+ <small>(Qo::Matchers)</small>
230
+
231
+ </li>
232
+
219
233
  <li>
220
234
  <span class='object_link'><a href="Qo/PublicApi.html" title="Qo::PublicApi (module)">PublicApi</a></span>
221
235
 
@@ -248,9 +262,9 @@
248
262
  </div>
249
263
 
250
264
  <div id="footer">
251
- Generated on Sun Apr 15 20:29:44 2018 by
265
+ Generated on Sun Aug 5 20:52:09 2018 by
252
266
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
253
- 0.9.12 (ruby-2.4.4).
267
+ 0.9.12 (ruby-2.5.1).
254
268
  </div>
255
269
 
256
270
  </div>
data/docs/class_list.html CHANGED
@@ -43,7 +43,7 @@
43
43
 
44
44
  <ul id="full_list" class="class">
45
45
  <li id="object_" class="odd"><div class="item" style="padding-left:30px"><span class='object_link'><a href="top-level-namespace.html" title="Top Level Namespace (root)">Top Level Namespace</a></span></div></li>
46
- <li id='object_Qo' class='even'><div class='item' style='padding-left:30px'><a class='toggle'></a> <span class='object_link'><a href="Qo.html" title="Qo (module)">Qo</a></span><small class='search_info'>Top Level Namespace</small></div><ul><li id='object_Qo::Exceptions' class='collapsed odd'><div class='item' style='padding-left:45px'><a class='toggle'></a> <span class='object_link'><a href="Qo/Exceptions.html" title="Qo::Exceptions (module)">Exceptions</a></span><small class='search_info'>Qo</small></div><ul><li id='object_Qo::Exceptions::MultipleMatchersProvided' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="Qo/Exceptions/MultipleMatchersProvided.html" title="Qo::Exceptions::MultipleMatchersProvided (class)">MultipleMatchersProvided</a></span> &lt; ArgumentError<small class='search_info'>Qo::Exceptions</small></div></li><li id='object_Qo::Exceptions::NoMatchersProvided' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="Qo/Exceptions/NoMatchersProvided.html" title="Qo::Exceptions::NoMatchersProvided (class)">NoMatchersProvided</a></span> &lt; ArgumentError<small class='search_info'>Qo::Exceptions</small></div></li><li id='object_Qo::Exceptions::NotAllGuardMatchersProvided' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="Qo/Exceptions/NotAllGuardMatchersProvided.html" title="Qo::Exceptions::NotAllGuardMatchersProvided (class)">NotAllGuardMatchersProvided</a></span> &lt; ArgumentError<small class='search_info'>Qo::Exceptions</small></div></li></ul></li><li id='object_Qo::Helpers' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Qo/Helpers.html" title="Qo::Helpers (module)">Helpers</a></span><small class='search_info'>Qo</small></div></li><li id='object_Qo::Matchers' class='collapsed odd'><div class='item' style='padding-left:45px'><a class='toggle'></a> <span class='object_link'><a href="Qo/Matchers.html" title="Qo::Matchers (module)">Matchers</a></span><small class='search_info'>Qo</small></div><ul><li id='object_Qo::Matchers::ArrayMatcher' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="Qo/Matchers/ArrayMatcher.html" title="Qo::Matchers::ArrayMatcher (class)">ArrayMatcher</a></span> &lt; BaseMatcher<small class='search_info'>Qo::Matchers</small></div></li><li id='object_Qo::Matchers::BaseMatcher' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="Qo/Matchers/BaseMatcher.html" title="Qo::Matchers::BaseMatcher (class)">BaseMatcher</a></span> &lt; Object<small class='search_info'>Qo::Matchers</small></div></li><li id='object_Qo::Matchers::GuardBlockMatcher' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="Qo/Matchers/GuardBlockMatcher.html" title="Qo::Matchers::GuardBlockMatcher (class)">GuardBlockMatcher</a></span> &lt; BaseMatcher<small class='search_info'>Qo::Matchers</small></div></li><li id='object_Qo::Matchers::HashMatcher' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="Qo/Matchers/HashMatcher.html" title="Qo::Matchers::HashMatcher (class)">HashMatcher</a></span> &lt; BaseMatcher<small class='search_info'>Qo::Matchers</small></div></li><li id='object_Qo::Matchers::PatternMatch' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="Qo/Matchers/PatternMatch.html" title="Qo::Matchers::PatternMatch (class)">PatternMatch</a></span> &lt; Object<small class='search_info'>Qo::Matchers</small></div></li></ul></li><li id='object_Qo::PublicApi' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Qo/PublicApi.html" title="Qo::PublicApi (module)">PublicApi</a></span><small class='search_info'>Qo</small></div></li></ul></li>
46
+ <li id='object_Qo' class='even'><div class='item' style='padding-left:30px'><a class='toggle'></a> <span class='object_link'><a href="Qo.html" title="Qo (module)">Qo</a></span><small class='search_info'>Top Level Namespace</small></div><ul><li id='object_Qo::Exceptions' class='collapsed odd'><div class='item' style='padding-left:45px'><a class='toggle'></a> <span class='object_link'><a href="Qo/Exceptions.html" title="Qo::Exceptions (module)">Exceptions</a></span><small class='search_info'>Qo</small></div><ul><li id='object_Qo::Exceptions::MultipleElseClauses' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="Qo/Exceptions/MultipleElseClauses.html" title="Qo::Exceptions::MultipleElseClauses (class)">MultipleElseClauses</a></span> &lt; ArgumentError<small class='search_info'>Qo::Exceptions</small></div></li><li id='object_Qo::Exceptions::MultipleMatchersProvided' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="Qo/Exceptions/MultipleMatchersProvided.html" title="Qo::Exceptions::MultipleMatchersProvided (class)">MultipleMatchersProvided</a></span> &lt; ArgumentError<small class='search_info'>Qo::Exceptions</small></div></li><li id='object_Qo::Exceptions::NoMatchersProvided' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="Qo/Exceptions/NoMatchersProvided.html" title="Qo::Exceptions::NoMatchersProvided (class)">NoMatchersProvided</a></span> &lt; ArgumentError<small class='search_info'>Qo::Exceptions</small></div></li><li id='object_Qo::Exceptions::NotAllGuardMatchersProvided' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="Qo/Exceptions/NotAllGuardMatchersProvided.html" title="Qo::Exceptions::NotAllGuardMatchersProvided (class)">NotAllGuardMatchersProvided</a></span> &lt; ArgumentError<small class='search_info'>Qo::Exceptions</small></div></li></ul></li><li id='object_Qo::Helpers' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Qo/Helpers.html" title="Qo::Helpers (module)">Helpers</a></span><small class='search_info'>Qo</small></div></li><li id='object_Qo::Matchers' class='collapsed odd'><div class='item' style='padding-left:45px'><a class='toggle'></a> <span class='object_link'><a href="Qo/Matchers.html" title="Qo::Matchers (module)">Matchers</a></span><small class='search_info'>Qo</small></div><ul><li id='object_Qo::Matchers::ArrayMatcher' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="Qo/Matchers/ArrayMatcher.html" title="Qo::Matchers::ArrayMatcher (class)">ArrayMatcher</a></span> &lt; BaseMatcher<small class='search_info'>Qo::Matchers</small></div></li><li id='object_Qo::Matchers::BaseMatcher' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="Qo/Matchers/BaseMatcher.html" title="Qo::Matchers::BaseMatcher (class)">BaseMatcher</a></span> &lt; Object<small class='search_info'>Qo::Matchers</small></div></li><li id='object_Qo::Matchers::GuardBlockMatcher' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="Qo/Matchers/GuardBlockMatcher.html" title="Qo::Matchers::GuardBlockMatcher (class)">GuardBlockMatcher</a></span> &lt; BaseMatcher<small class='search_info'>Qo::Matchers</small></div></li><li id='object_Qo::Matchers::HashMatcher' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="Qo/Matchers/HashMatcher.html" title="Qo::Matchers::HashMatcher (class)">HashMatcher</a></span> &lt; BaseMatcher<small class='search_info'>Qo::Matchers</small></div></li><li id='object_Qo::Matchers::PatternMatch' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="Qo/Matchers/PatternMatch.html" title="Qo::Matchers::PatternMatch (class)">PatternMatch</a></span> &lt; Object<small class='search_info'>Qo::Matchers</small></div></li><li id='object_Qo::Matchers::PatternMatchBlock' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="Qo/Matchers/PatternMatchBlock.html" title="Qo::Matchers::PatternMatchBlock (class)">PatternMatchBlock</a></span> &lt; Object<small class='search_info'>Qo::Matchers</small></div></li></ul></li><li id='object_Qo::PublicApi' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Qo/PublicApi.html" title="Qo::PublicApi (module)">PublicApi</a></span><small class='search_info'>Qo</small></div></li></ul></li>
47
47
 
48
48
  </ul>
49
49
  </div>
@@ -63,10 +63,12 @@
63
63
  <a href="https://codeclimate.com/github/baweaver/qo/maintainability"><img src="https://api.codeclimate.com/v1/badges/186e9cbb7003842acaf0/maintainability" alt="Maintainability"></a>
64
64
  <a href="https://badge.fury.io/rb/qo"><img src="https://badge.fury.io/rb/qo.svg" alt="Gem Version"></a></p>
65
65
 
66
- <p>Short for Query Object, my play at Ruby pattern matching and fluent querying</p>
66
+ <p>Short for Query Object, my play at Ruby pattern matching and fluent querying, <a href="img/whoa_lemur.png">pronounced &quot;Q-whoah&quot;</a>.</p>
67
67
 
68
68
  <p><img src="img/qo_logo.png" alt="Qo Lemur logo"></p>
69
69
 
70
+ <p><a href="https://baweaver.github.io/qo/">Read the Docs for more detailed information</a></p>
71
+
70
72
  <h2>How does it work?</h2>
71
73
 
72
74
  <p>Mostly by using Ruby language features like <code>to_proc</code> and <code>===</code>.</p>
@@ -87,33 +89,60 @@
87
89
 
88
90
  <h2>Usage</h2>
89
91
 
92
+ <p>Note that Qo uses the <a href="https://www.github.com/baweaver/any">Any</a> gem for wildcard matching. Any will respond true to any <code>==</code> or <code>===</code> query against it,
93
+ and is included in the gem.</p>
94
+
90
95
  <h3>Quick Start</h3>
91
96
 
92
97
  <p>Qo is used for pattern matching in Ruby. All Qo matchers respond to <code>===</code> and <code>to_proc</code> meaning they can be used with <code>case</code> and Enumerable functions alike:</p>
93
98
 
94
99
  <pre class="code ruby"><code class="ruby"><span class='kw'>case</span> <span class='lbracket'>[</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='int'>42</span><span class='rbracket'>]</span>
95
- <span class='kw'>when</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='symbol'>:*</span><span class='comma'>,</span> <span class='int'>42</span><span class='rbracket'>]</span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Truly the one answer</span><span class='tstring_end'>&#39;</span></span>
100
+ <span class='kw'>when</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'>Any</span><span class='comma'>,</span> <span class='int'>42</span><span class='rbracket'>]</span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Truly the one answer</span><span class='tstring_end'>&#39;</span></span>
96
101
  <span class='kw'>else</span> <span class='kw'>nil</span>
97
102
  <span class='kw'>end</span>
98
103
 
99
104
  <span class='comment'># Run a select like an AR query, getting the age attribute against a range
100
105
  </span><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'>age:</span> <span class='int'>18</span><span class='op'>..</span><span class='int'>30</span><span class='rbracket'>]</span><span class='rparen'>)</span>
106
+ </code></pre>
107
+
108
+ <p>How about some pattern matching? There are two styles:</p>
109
+
110
+ <h4>Pattern Match</h4>
111
+
112
+ <p>The original style</p>
101
113
 
102
- <span class='comment'># How about some &quot;right-hand assignment&quot; pattern matching
114
+ <pre class="code ruby"><code class="ruby"><span class='comment'># How about some &quot;right-hand assignment&quot; pattern matching
103
115
  </span><span class='id identifier rubyid_name_longer_than_three'>name_longer_than_three</span> <span class='op'>=</span> <span class='tlambda'>-&gt;</span> <span class='id identifier rubyid_person'>person</span> <span class='tlambeg'>{</span> <span class='id identifier rubyid_person'>person</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>&gt;</span> <span class='int'>3</span> <span class='rbrace'>}</span>
104
116
  <span class='id identifier rubyid_people_with_truncated_names'>people_with_truncated_names</span> <span class='op'>=</span> <span class='id identifier rubyid_people'>people</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</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='period'>.</span><span class='id identifier rubyid_match'><span class='object_link'><a href="Qo/PublicApi.html#match-instance_method" title="Qo::PublicApi#match (method)">match</a></span></span><span class='lparen'>(</span>
105
117
  <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='id identifier rubyid_name_longer_than_three'>name_longer_than_three</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_person'>person</span><span class='op'>|</span> <span class='const'>Person</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_person'>person</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='op'>..</span><span class='int'>2</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_person'>person</span><span class='period'>.</span><span class='id identifier rubyid_age'>age</span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='comma'>,</span>
106
- <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> <span class='comment'># Identity function, catch-all
118
+ <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'>Any</span><span class='rparen'>)</span> <span class='comment'># Identity function, catch-all
107
119
  </span><span class='rparen'>)</span><span class='rparen'>)</span>
108
120
 
109
121
  <span class='comment'># And standalone like a case:
110
122
  </span><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="Qo/PublicApi.html#match-instance_method" title="Qo::PublicApi#match (method)">match</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_people'>people</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='comma'>,</span>
111
123
  <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='label'>age:</span> <span class='int'>10</span><span class='op'>..</span><span class='int'>19</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_person'>person</span><span class='op'>|</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_person'>person</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_content'> is a teen that&#39;s </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_person'>person</span><span class='period'>.</span><span class='id identifier rubyid_age'>age</span><span class='embexpr_end'>}</span><span class='tstring_content'> years old</span><span class='tstring_end'>&quot;</span></span> <span class='rbrace'>}</span><span class='comma'>,</span>
112
- <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> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_person'>person</span><span class='op'>|</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_person'>person</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_content'> is </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_person'>person</span><span class='period'>.</span><span class='id identifier rubyid_age'>age</span><span class='embexpr_end'>}</span><span class='tstring_content'> years old</span><span class='tstring_end'>&quot;</span></span> <span class='rbrace'>}</span>
124
+ <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'>Any</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_person'>person</span><span class='op'>|</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_person'>person</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_content'> is </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_person'>person</span><span class='period'>.</span><span class='id identifier rubyid_age'>age</span><span class='embexpr_end'>}</span><span class='tstring_content'> years old</span><span class='tstring_end'>&quot;</span></span> <span class='rbrace'>}</span>
113
125
  <span class='rparen'>)</span>
114
126
  </code></pre>
115
127
 
116
- <p>Get a lot more expressiveness in your queries and transformations. Read on for the full details.</p>
128
+ <h4>Pattern Match Block</h4>
129
+
130
+ <p>The new style, likely to take over in <code>v1.0.0</code> after testing:</p>
131
+
132
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_name_longer_than_three'>name_longer_than_three</span> <span class='op'>=</span> <span class='tlambda'>-&gt;</span> <span class='id identifier rubyid_person'>person</span> <span class='tlambeg'>{</span> <span class='id identifier rubyid_person'>person</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>&gt;</span> <span class='int'>3</span> <span class='rbrace'>}</span>
133
+ <span class='id identifier rubyid_people_with_truncated_names'>people_with_truncated_names</span> <span class='op'>=</span> <span class='id identifier rubyid_people'>people</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</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='period'>.</span><span class='id identifier rubyid_match'><span class='object_link'><a href="Qo/PublicApi.html#match-instance_method" title="Qo::PublicApi#match (method)">match</a></span></span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_m'>m</span><span class='op'>|</span>
134
+ <span class='id identifier rubyid_m'>m</span><span class='period'>.</span><span class='id identifier rubyid_when'>when</span><span class='lparen'>(</span><span class='id identifier rubyid_name_longer_than_three'>name_longer_than_three</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_person'>person</span><span class='op'>|</span> <span class='const'>Person</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_person'>person</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='op'>..</span><span class='int'>2</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_person'>person</span><span class='period'>.</span><span class='id identifier rubyid_age'>age</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
135
+ <span class='id identifier rubyid_m'>m</span><span class='period'>.</span><span class='id identifier rubyid_else'>else</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:itself</span><span class='rparen'>)</span>
136
+ <span class='rbrace'>}</span><span class='rparen'>)</span>
137
+
138
+ <span class='comment'># And standalone like a case:
139
+ </span><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="Qo/PublicApi.html#match-instance_method" title="Qo::PublicApi#match (method)">match</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_people'>people</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_m'>m</span><span class='op'>|</span>
140
+ <span class='id identifier rubyid_m'>m</span><span class='period'>.</span><span class='id identifier rubyid_when'>when</span><span class='lparen'>(</span><span class='label'>age:</span> <span class='int'>10</span><span class='op'>..</span><span class='int'>19</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_person'>person</span><span class='op'>|</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_person'>person</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_content'> is a teen that&#39;s </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_person'>person</span><span class='period'>.</span><span class='id identifier rubyid_age'>age</span><span class='embexpr_end'>}</span><span class='tstring_content'> years old</span><span class='tstring_end'>&quot;</span></span> <span class='rbrace'>}</span>
141
+ <span class='id identifier rubyid_m'>m</span><span class='period'>.</span><span class='id identifier rubyid_else'>else</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_person'>person</span><span class='op'>|</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_person'>person</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_content'> is </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_person'>person</span><span class='period'>.</span><span class='id identifier rubyid_age'>age</span><span class='embexpr_end'>}</span><span class='tstring_content'> years old</span><span class='tstring_end'>&quot;</span></span> <span class='rbrace'>}</span>
142
+ <span class='rbrace'>}</span>
143
+ </code></pre>
144
+
145
+ <p>(More details coming on the difference and planned 1.0.0 APIs)</p>
117
146
 
118
147
  <h3>Qo&#39;isms</h3>
119
148
 
@@ -157,14 +186,14 @@
157
186
 
158
187
  <h3>1 - Wildcard Matching</h3>
159
188
 
160
- <p>Qo has a concept of a Wildcard, <code>:*</code>, which will match against any value</p>
189
+ <p>Qo has a concept of a Wildcard, <code>Any</code>, which will match against any value</p>
161
190
 
162
- <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='symbol'>:*</span><span class='comma'>,</span> <span class='symbol'>:*</span><span class='rbracket'>]</span> <span class='op'>===</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Robert</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='int'>22</span><span class='rbracket'>]</span> <span class='comment'># true
191
+ <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='const'>Any</span><span class='comma'>,</span> <span class='const'>Any</span><span class='rbracket'>]</span> <span class='op'>===</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Robert</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='int'>22</span><span class='rbracket'>]</span> <span class='comment'># true
163
192
  </span></code></pre>
164
193
 
165
194
  <p>A single wildcard will match anything, and can frequently be used as an always true:</p>
166
195
 
167
- <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='symbol'>:*</span><span class='rbracket'>]</span> <span class='op'>===</span> <span class='symbol'>:literally_anything_here</span>
196
+ <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='const'>Any</span><span class='rbracket'>]</span> <span class='op'>===</span> <span class='symbol'>:literally_anything_here</span>
168
197
  </code></pre>
169
198
 
170
199
  <h3>2 - Array Matching</h3>
@@ -181,62 +210,40 @@
181
210
  <p>When an Array matcher is run against an Array, it will compare elements by index in the following priority:</p>
182
211
 
183
212
  <ol>
184
- <li>Was a wildcard provided?</li>
185
213
  <li>Does it case match (<code>===</code>)?</li>
186
214
  <li>Does it have a predicate method by that name that matches?</li>
187
215
  </ol>
188
216
 
189
217
  <p>This functionality is left biased and permissive, meaning that if the right side of the argument is longer it will ignore those items in the match. If it&#39;s shorter? Not so much.</p>
190
218
 
191
- <h5>2.1.1 - Wildcard provided</h5>
192
-
193
- <pre class="code ruby"><code class="ruby"><span class='comment'># Standalone
194
- </span>
195
- <span class='const'><span class='object_link'><a href="Qo.html" title="Qo (module)">Qo</a></span></span><span class='lbracket'>[</span><span class='symbol'>:*</span><span class='comma'>,</span> <span class='symbol'>:*</span><span class='rbracket'>]</span> <span class='op'>===</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Robert</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='int'>22</span><span class='rbracket'>]</span>
196
- <span class='comment'># =&gt; true
197
- </span>
198
- <span class='comment'># Case statement
199
- </span>
200
- <span class='kw'>case</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Roberta</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='int'>22</span><span class='rbracket'>]</span>
201
- <span class='kw'>when</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='symbol'>:*</span><span class='comma'>,</span> <span class='symbol'>:*</span><span class='rbracket'>]</span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>it matched</span><span class='tstring_end'>&#39;</span></span>
202
- <span class='kw'>else</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>will not ever be reached</span><span class='tstring_end'>&#39;</span></span>
203
- <span class='kw'>end</span>
204
- <span class='comment'># =&gt; &#39;it matched&#39;
205
- </span>
206
- <span class='comment'># Select
207
- </span>
208
- <span class='id identifier rubyid_people_arrays'>people_arrays</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='symbol'>:*</span><span class='comma'>,</span> <span class='symbol'>:*</span><span class='rbracket'>]</span><span class='rparen'>)</span>
209
- <span class='comment'># =&gt; [[&#39;Robert&#39;, 22], [&#39;Roberta&#39;, 22], [&#39;Foo&#39;, 42], [&#39;Bar&#39;, 18]]
210
- </span></code></pre>
211
-
212
- <h5>2.1.2 - Case Match present</h5>
219
+ <h5>2.1.1 - Case Match present</h5>
213
220
 
214
221
  <p>We&#39;ve seen some case matching so far with <code>Range</code> and <code>Regex</code>:</p>
215
222
 
216
223
  <pre class="code ruby"><code class="ruby"><span class='comment'># Standalone
217
224
  </span>
218
- <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'>Rob</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='symbol'>:*</span><span class='rbracket'>]</span> <span class='op'>===</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Robert</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='int'>22</span><span class='rbracket'>]</span>
225
+ <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'>Rob</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='const'>Any</span><span class='rbracket'>]</span> <span class='op'>===</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Robert</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='int'>22</span><span class='rbracket'>]</span>
219
226
  <span class='comment'># =&gt; true
220
227
  </span>
221
228
  <span class='comment'># Case statement
222
229
  </span>
223
230
  <span class='kw'>case</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Roberta</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='int'>22</span><span class='rbracket'>]</span>
224
- <span class='kw'>when</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='symbol'>:*</span><span class='comma'>,</span> <span class='int'>0</span><span class='op'>..</span><span class='int'>9</span><span class='rbracket'>]</span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>child</span><span class='tstring_end'>&#39;</span></span>
225
- <span class='kw'>when</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='symbol'>:*</span><span class='comma'>,</span> <span class='int'>10</span><span class='op'>..</span><span class='int'>19</span><span class='rbracket'>]</span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>teen</span><span class='tstring_end'>&#39;</span></span>
226
- <span class='kw'>when</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='symbol'>:*</span><span class='comma'>,</span> <span class='int'>20</span><span class='op'>..</span><span class='int'>99</span><span class='rbracket'>]</span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>adult</span><span class='tstring_end'>&#39;</span></span>
231
+ <span class='kw'>when</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'>Any</span><span class='comma'>,</span> <span class='int'>0</span><span class='op'>..</span><span class='int'>9</span><span class='rbracket'>]</span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>child</span><span class='tstring_end'>&#39;</span></span>
232
+ <span class='kw'>when</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'>Any</span><span class='comma'>,</span> <span class='int'>10</span><span class='op'>..</span><span class='int'>19</span><span class='rbracket'>]</span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>teen</span><span class='tstring_end'>&#39;</span></span>
233
+ <span class='kw'>when</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'>Any</span><span class='comma'>,</span> <span class='int'>20</span><span class='op'>..</span><span class='int'>99</span><span class='rbracket'>]</span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>adult</span><span class='tstring_end'>&#39;</span></span>
227
234
  <span class='kw'>else</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>not sure</span><span class='tstring_end'>&#39;</span></span>
228
235
  <span class='kw'>end</span>
229
236
  <span class='comment'># =&gt; &#39;adult&#39;
230
237
  </span>
231
238
  <span class='comment'># Select
232
239
  </span>
233
- <span class='id identifier rubyid_people_arrays'>people_arrays</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='symbol'>:*</span><span class='comma'>,</span> <span class='int'>10</span><span class='op'>..</span><span class='int'>19</span><span class='rbracket'>]</span><span class='rparen'>)</span>
240
+ <span class='id identifier rubyid_people_arrays'>people_arrays</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='const'>Any</span><span class='comma'>,</span> <span class='int'>10</span><span class='op'>..</span><span class='int'>19</span><span class='rbracket'>]</span><span class='rparen'>)</span>
234
241
  <span class='comment'># =&gt; [[&#39;Bar&#39;, 18]]
235
242
  </span></code></pre>
236
243
 
237
- <h5>2.1.3 - Predicate Method matched</h5>
244
+ <h5>2.1.2 - Predicate Method matched</h5>
238
245
 
239
- <p>If no wildcard or case match is found, it will attempt to see if a predicate method by the same name exists, call it, and check the result:</p>
246
+ <p>If no case match is found, it will attempt to see if a predicate method by the same name exists, call it, and check the result:</p>
240
247
 
241
248
  <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_dirty_values'>dirty_values</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='kw'>true</span><span class='rbracket'>]</span>
242
249
 
@@ -248,14 +255,14 @@
248
255
  <span class='comment'># Case statement
249
256
  </span>
250
257
  <span class='kw'>case</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Roberta</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='kw'>nil</span><span class='rbracket'>]</span>
251
- <span class='kw'>when</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='symbol'>:*</span><span class='comma'>,</span> <span class='symbol'>:nil?</span><span class='rbracket'>]</span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>no age</span><span class='tstring_end'>&#39;</span></span>
258
+ <span class='kw'>when</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'>Any</span><span class='comma'>,</span> <span class='symbol'>:nil?</span><span class='rbracket'>]</span> <span class='kw'>then</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>no age</span><span class='tstring_end'>&#39;</span></span>
252
259
  <span class='kw'>else</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>not sure</span><span class='tstring_end'>&#39;</span></span>
253
260
  <span class='kw'>end</span>
254
261
  <span class='comment'># =&gt; &#39;no age&#39;
255
262
  </span>
256
263
  <span class='comment'># Select
257
264
  </span>
258
- <span class='id identifier rubyid_people_arrays'>people_arrays</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='symbol'>:*</span><span class='comma'>,</span> <span class='symbol'>:even?</span><span class='rbracket'>]</span><span class='rparen'>)</span>
265
+ <span class='id identifier rubyid_people_arrays'>people_arrays</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='const'>Any</span><span class='comma'>,</span> <span class='symbol'>:even?</span><span class='rbracket'>]</span><span class='rparen'>)</span>
259
266
  <span class='comment'># =&gt; [[&quot;Robert&quot;, 22], [&quot;Roberta&quot;, 22], [&quot;Foo&quot;, 42], [&quot;Bar&quot;, 18]]
260
267
  </span></code></pre>
261
268
 
@@ -264,21 +271,13 @@
264
271
  <p>When an Array matcher is matched against anything other than an Array it will follow the priority:</p>
265
272
 
266
273
  <ol>
267
- <li>Was a wildcard provided?</li>
268
274
  <li>Does it case match (<code>===</code>)?</li>
269
275
  <li>Does it have a predicate method by that name that matches?</li>
270
276
  </ol>
271
277
 
272
278
  <p>Every argument provided will be run against the target object.</p>
273
279
 
274
- <h5>2.2.1 - Wildcard provided</h5>
275
-
276
- <p>A wildcard in an Array to Object match is functionally an always true, but can be used as such:</p>
277
-
278
- <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='symbol'>:*</span><span class='rbracket'>]</span> <span class='op'>===</span> <span class='symbol'>:literally_anything_here</span>
279
- </code></pre>
280
-
281
- <h5>2.2.2 - Case Match present</h5>
280
+ <h5>2.2.1 - Case Match present</h5>
282
281
 
283
282
  <pre class="code ruby"><code class="ruby"><span class='comment'># Standalone
284
283
  </span>
@@ -293,7 +292,7 @@
293
292
  <span class='comment'># =&gt; [10, &quot;string&quot;]
294
293
  </span></code></pre>
295
294
 
296
- <h5>2.2.3 - Predicate Method matched</h5>
295
+ <h5>2.2.2 - Predicate Method matched</h5>
297
296
 
298
297
  <p>Now this is where some of the fun starts in</p>
299
298
 
@@ -325,7 +324,6 @@
325
324
  <ol>
326
325
  <li>Does the key exist on the other hash?</li>
327
326
  <li>Are the match value and match target hashes?</li>
328
- <li>Was a wildcard value provided?</li>
329
327
  <li>Does the target object&#39;s value case match against the match value?</li>
330
328
  <li>Does the target object&#39;s value predicate match against the match value?</li>
331
329
  <li>What about the String version of the match key? Abort if it can&#39;t coerce.</li>
@@ -375,15 +373,7 @@
375
373
  <span class='rbrace'>}</span><span class='rparen'>)</span>
376
374
  </code></pre>
377
375
 
378
- <h5>3.1.3 - Wildcard provided</h5>
379
-
380
- <p>As with other wildcards, if the value matched against is a wildcard it&#39;ll always get through:</p>
381
-
382
- <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='symbol'>:*</span><span class='rbracket'>]</span> <span class='op'>===</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='rbrace'>}</span>
383
- <span class='comment'># =&gt; true
384
- </span></code></pre>
385
-
386
- <h5>3.1.4 - Case match present</h5>
376
+ <h5>3.1.3 - Case match present</h5>
387
377
 
388
378
  <p>If a case match is present for the key, it&#39;ll try and compare:</p>
389
379
 
@@ -407,7 +397,7 @@
407
397
  <span class='comment'># =&gt; [{:name=&gt;&quot;Robert&quot;, :age=&gt;22}, {:name=&gt;&quot;Roberta&quot;, :age=&gt;22}, {:name=&gt;&quot;Bar&quot;, :age=&gt;18}]
408
398
  </span></code></pre>
409
399
 
410
- <h5>3.1.5 - Predicate match present</h5>
400
+ <h5>3.1.4 - Predicate match present</h5>
411
401
 
412
402
  <p>Much like our array friend above, if a predicate style method is present see if it&#39;ll work</p>
413
403
 
@@ -433,7 +423,7 @@
433
423
 
434
424
  <p>Careful though, if the key doesn&#39;t exist that won&#39;t match. I&#39;ll have to consider this one later.</p>
435
425
 
436
- <h5>3.1.6 - String variant present</h5>
426
+ <h5>3.1.5 - String variant present</h5>
437
427
 
438
428
  <p>Coerces the key into a string if possible, and sees if that can provide a valid case match</p>
439
429
 
@@ -441,7 +431,6 @@
441
431
 
442
432
  <ol>
443
433
  <li>Does the object respond to the match key?</li>
444
- <li>Was a wildcard value provided?</li>
445
434
  <li>Does the result of sending the match key as a method case match the provided value?</li>
446
435
  <li>Does a predicate method exist for it?</li>
447
436
  </ol>
@@ -450,11 +439,7 @@
450
439
 
451
440
  <p>If it doesn&#39;t know how to deal with it, false out.</p>
452
441
 
453
- <h5>3.2.2 - Wildcard provided</h5>
454
-
455
- <p>Same as other wildcards, but if the object doesn&#39;t respond to the method you specify it&#39;ll have false&#39;d out before it reaches here.</p>
456
-
457
- <h5>3.2.3 - Case match present</h5>
442
+ <h5>3.2.2 - Case match present</h5>
458
443
 
459
444
  <p>This is where we can get into some interesting code, much like the hash selections above</p>
460
445
 
@@ -477,7 +462,7 @@
477
462
  <span class='comment'># =&gt; [Person(Robert, 22), Person(Roberta, 22)]
478
463
  </span></code></pre>
479
464
 
480
- <h5>3.2.4 - Predicate match present</h5>
465
+ <h5>3.2.3 - Predicate match present</h5>
481
466
 
482
467
  <pre class="code ruby"><code class="ruby"><span class='comment'># Standalone
483
468
  </span>
@@ -503,15 +488,15 @@
503
488
  <p>This is where I start going a bit off into the weeds. We&#39;re going to try and get RHA style pattern matching in Ruby.</p>
504
489
 
505
490
  <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='period'>.</span><span class='id identifier rubyid_match'><span class='object_link'><a href="Qo/PublicApi.html#match-instance_method" title="Qo::PublicApi#match (method)">match</a></span></span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Robert</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='int'>22</span><span class='rbracket'>]</span><span class='comma'>,</span>
506
- <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='comma'>,</span> <span class='int'>20</span><span class='op'>..</span><span class='int'>99</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_n'>n</span><span class='comma'>,</span> <span class='id identifier rubyid_a'>a</span><span class='op'>|</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_n'>n</span><span class='embexpr_end'>}</span><span class='tstring_content'> is an adult that is </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_a'>a</span><span class='embexpr_end'>}</span><span class='tstring_content'> years old</span><span class='tstring_end'>&quot;</span></span> <span class='rbrace'>}</span><span class='comma'>,</span>
507
- <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>
491
+ <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'>Any</span><span class='comma'>,</span> <span class='int'>20</span><span class='op'>..</span><span class='int'>99</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_n'>n</span><span class='comma'>,</span> <span class='id identifier rubyid_a'>a</span><span class='op'>|</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_n'>n</span><span class='embexpr_end'>}</span><span class='tstring_content'> is an adult that is </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_a'>a</span><span class='embexpr_end'>}</span><span class='tstring_content'> years old</span><span class='tstring_end'>&quot;</span></span> <span class='rbrace'>}</span><span class='comma'>,</span>
492
+ <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'>Any</span><span class='rparen'>)</span>
508
493
  <span class='rparen'>)</span>
509
494
  <span class='comment'># =&gt; &quot;Robert is an adult that is 22 years old&quot;
510
495
  </span></code></pre>
511
496
 
512
497
  <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='period'>.</span><span class='id identifier rubyid_match'><span class='object_link'><a href="Qo/PublicApi.html#match-instance_method" title="Qo::PublicApi#match (method)">match</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_people_objects'>people_objects</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='comma'>,</span>
513
- <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='label'>name:</span> <span class='symbol'>:*</span><span class='comma'>,</span> <span class='label'>age:</span> <span class='int'>20</span><span class='op'>..</span><span class='int'>99</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_person'>person</span><span class='op'>|</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_person'>person</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_content'> is an adult that is </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_person'>person</span><span class='period'>.</span><span class='id identifier rubyid_age'>age</span><span class='embexpr_end'>}</span><span class='tstring_content'> years old</span><span class='tstring_end'>&quot;</span></span> <span class='rbrace'>}</span><span class='comma'>,</span>
514
- <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>
498
+ <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='label'>name:</span> <span class='const'>Any</span><span class='comma'>,</span> <span class='label'>age:</span> <span class='int'>20</span><span class='op'>..</span><span class='int'>99</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_person'>person</span><span class='op'>|</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_person'>person</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_content'> is an adult that is </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_person'>person</span><span class='period'>.</span><span class='id identifier rubyid_age'>age</span><span class='embexpr_end'>}</span><span class='tstring_content'> years old</span><span class='tstring_end'>&quot;</span></span> <span class='rbrace'>}</span><span class='comma'>,</span>
499
+ <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'>Any</span><span class='rparen'>)</span>
515
500
  <span class='rparen'>)</span>
516
501
  </code></pre>
517
502
 
@@ -533,7 +518,7 @@
533
518
  <span class='id identifier rubyid_person'>person</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='id identifier rubyid_person'>person</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='lbracket'>[</span><span class='int'>0</span><span class='op'>..</span><span class='int'>2</span><span class='rbracket'>]</span>
534
519
  <span class='id identifier rubyid_person'>person</span>
535
520
  <span class='rbrace'>}</span><span class='comma'>,</span>
536
- <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>
521
+ <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'>Any</span><span class='rparen'>)</span>
537
522
  <span class='rparen'>)</span><span class='rparen'>)</span>
538
523
 
539
524
  <span class='comment'># =&gt; [Person(age: 22, name: &quot;Rob&quot;), Person(age: 22, name: &quot;Rob&quot;), Person(age: 42, name: &quot;Foo&quot;), Person(age: 17, name: &quot;Bar&quot;)]
@@ -582,7 +567,7 @@
582
567
 
583
568
  <p>These examples will grow over the next few weeks as I think of more fun things to do with Qo. PRs welcome if you find fun uses!</p>
584
569
 
585
- <h4>5.1 - JSON</h4>
570
+ <h4>5.1 - JSON and HTTP</h4>
586
571
 
587
572
  <blockquote>
588
573
  <p>Note that Qo does not support deep querying of hashes (yet)</p>
@@ -627,6 +612,35 @@
627
612
 
628
613
  <p>Nifty!</p>
629
614
 
615
+ <h5>Yield Self HTTP status matching</h5>
616
+
617
+ <p>You can even use <code>#yield_self</code> to pipe values into a pattern matching block. In
618
+ this particular case it&#39;ll let you check against the type signatures of the
619
+ HTTP responses.</p>
620
+
621
+ <pre class="code ruby"><code class="ruby"><span class='kw'>def</span> <span class='id identifier rubyid_get_url'>get_url</span><span class='lparen'>(</span><span class='id identifier rubyid_url'>url</span><span class='rparen'>)</span>
622
+ <span class='const'>Net</span><span class='op'>::</span><span class='const'>HTTP</span><span class='period'>.</span><span class='id identifier rubyid_get_response'>get_response</span><span class='lparen'>(</span><span class='const'>URI</span><span class='lparen'>(</span><span class='id identifier rubyid_url'>url</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_yield_self'>yield_self</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='period'>.</span><span class='id identifier rubyid_match'><span class='object_link'><a href="Qo/PublicApi.html#match-instance_method" title="Qo::PublicApi#match (method)">match</a></span></span><span class='lparen'>(</span>
623
+ <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'>Net</span><span class='op'>::</span><span class='const'>HTTPSuccess</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_response'>response</span><span class='op'>|</span> <span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_body'>body</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='rbrace'>}</span><span class='comma'>,</span>
624
+ <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'>Any</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_response'>response</span><span class='op'>|</span> <span class='id identifier rubyid_raise'>raise</span> <span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span> <span class='rbrace'>}</span>
625
+ <span class='rparen'>)</span><span class='rparen'>)</span>
626
+ <span class='kw'>end</span>
627
+
628
+ <span class='id identifier rubyid_get_url'>get_url</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>https://github.com/baweaver/qo</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
629
+ <span class='comment'># =&gt; 142387
630
+ </span><span class='id identifier rubyid_get_url'>get_url</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>https://github.com/baweaver/qo/does_not_exist</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
631
+ <span class='comment'># =&gt; RuntimeError: Not Found
632
+ </span></code></pre>
633
+
634
+ <p>The difference between this and case? Well, the first is you can pass this to
635
+ <code>yield_self</code> for a more inline solution. The second is that any Qo matcher can
636
+ be used in there, including predicate and content checks on the body:</p>
637
+
638
+ <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='period'>.</span><span class='id identifier rubyid_m'>m</span><span class='lparen'>(</span><span class='const'>Net</span><span class='op'>::</span><span class='const'>HTTPSuccess</span><span class='comma'>,</span> <span class='label'>body:</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>Qo</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span>
639
+ </code></pre>
640
+
641
+ <p>You could put as many checks as you want in there, or use different Qo matchers
642
+ nested to get even further in.</p>
643
+
630
644
  <h4>5.2 - Opsy Stuff</h4>
631
645
 
632
646
  <h5>5.2.1 - NMap</h5>
@@ -691,9 +705,9 @@ hosts.select(&amp;Qo[IPAddr.new(&#39;192.168.1.1/8&#39;)])
691
705
  </div></div>
692
706
 
693
707
  <div id="footer">
694
- Generated on Sun Apr 15 20:29:44 2018 by
708
+ Generated on Sun Aug 5 20:52:09 2018 by
695
709
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
696
- 0.9.12 (ruby-2.4.4).
710
+ 0.9.12 (ruby-2.5.1).
697
711
  </div>
698
712
 
699
713
  </div>