csv_decision 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/README.md +43 -19
  4. data/csv_decision.gemspec +1 -1
  5. data/doc/CSVDecision.html +6 -6
  6. data/doc/CSVDecision/CellValidationError.html +1 -1
  7. data/doc/CSVDecision/Columns.html +124 -42
  8. data/doc/CSVDecision/Columns/Dictionary.html +101 -7
  9. data/doc/CSVDecision/Data.html +1 -1
  10. data/doc/CSVDecision/Decision.html +444 -98
  11. data/doc/CSVDecision/Defaults.html +1 -1
  12. data/doc/CSVDecision/Dictionary.html +4 -4
  13. data/doc/CSVDecision/Dictionary/Entry.html +31 -31
  14. data/doc/CSVDecision/Error.html +1 -1
  15. data/doc/CSVDecision/FileError.html +1 -1
  16. data/doc/CSVDecision/Header.html +2 -2
  17. data/doc/CSVDecision/Index.html +1 -1
  18. data/doc/CSVDecision/Input.html +129 -3
  19. data/doc/CSVDecision/Load.html +1 -1
  20. data/doc/CSVDecision/Matchers.html +168 -41
  21. data/doc/CSVDecision/Matchers/Constant.html +7 -7
  22. data/doc/CSVDecision/Matchers/Function.html +1 -1
  23. data/doc/CSVDecision/Matchers/Guard.html +16 -16
  24. data/doc/CSVDecision/Matchers/Matcher.html +13 -13
  25. data/doc/CSVDecision/Matchers/Numeric.html +8 -14
  26. data/doc/CSVDecision/Matchers/Pattern.html +10 -10
  27. data/doc/CSVDecision/Matchers/Proc.html +1 -1
  28. data/doc/CSVDecision/Matchers/Range.html +1 -1
  29. data/doc/CSVDecision/Matchers/Symbol.html +19 -29
  30. data/doc/CSVDecision/Options.html +1 -1
  31. data/doc/CSVDecision/Parse.html +4 -4
  32. data/doc/CSVDecision/Paths.html +742 -0
  33. data/doc/CSVDecision/Result.html +139 -70
  34. data/doc/CSVDecision/Scan.html +313 -0
  35. data/doc/CSVDecision/Scan/InputHashes.html +369 -0
  36. data/doc/CSVDecision/ScanRow.html +1 -1
  37. data/doc/CSVDecision/Table.html +134 -52
  38. data/doc/CSVDecision/TableValidationError.html +1 -1
  39. data/doc/CSVDecision/Validate.html +1 -1
  40. data/doc/_index.html +26 -5
  41. data/doc/class_list.html +1 -1
  42. data/doc/file.README.html +50 -28
  43. data/doc/index.html +50 -28
  44. data/doc/method_list.html +234 -98
  45. data/doc/top-level-namespace.html +1 -1
  46. data/lib/csv_decision.rb +3 -0
  47. data/lib/csv_decision/columns.rb +11 -0
  48. data/lib/csv_decision/decision.rb +82 -56
  49. data/lib/csv_decision/dictionary.rb +5 -1
  50. data/lib/csv_decision/header.rb +1 -1
  51. data/lib/csv_decision/input.rb +14 -11
  52. data/lib/csv_decision/parse.rb +6 -2
  53. data/lib/csv_decision/paths.rb +78 -0
  54. data/lib/csv_decision/result.rb +42 -35
  55. data/lib/csv_decision/scan.rb +116 -0
  56. data/lib/csv_decision/table.rb +18 -7
  57. data/lib/csv_decision/validate.rb +1 -1
  58. data/spec/csv_decision/columns_spec.rb +14 -0
  59. data/spec/csv_decision/decision_spec.rb +1 -3
  60. data/spec/csv_decision/examples_spec.rb +25 -0
  61. data/spec/csv_decision/table_spec.rb +87 -0
  62. metadata +7 -2
@@ -469,7 +469,7 @@ array of arrays. Strips out empty columns/rows and comment cells.</p>
469
469
  </div>
470
470
 
471
471
  <div id="footer">
472
- Generated on Sun Jan 28 14:41:48 2018 by
472
+ Generated on Sun Feb 11 10:26:07 2018 by
473
473
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
474
474
  0.9.12 (ruby-2.4.0).
475
475
  </div>
@@ -118,6 +118,40 @@
118
118
 
119
119
 
120
120
 
121
+ <h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
122
+ <ul class="summary">
123
+
124
+ <li class="public ">
125
+ <span class="summary_signature">
126
+
127
+ <a href="#first_match-instance_method" title="#first_match (instance method)">#<strong>first_match</strong> &#x21d2; Boolean </a>
128
+
129
+
130
+
131
+ </span>
132
+
133
+
134
+
135
+
136
+ <span class="note title readonly">readonly</span>
137
+
138
+
139
+
140
+
141
+
142
+
143
+ <span class="private note title">private</span>
144
+
145
+
146
+ <span class="summary_desc"><div class='inline'>
147
+ <p>True if a first match decision table.</p>
148
+ </div></span>
149
+
150
+ </li>
151
+
152
+
153
+ </ul>
154
+
121
155
 
122
156
 
123
157
 
@@ -147,7 +181,7 @@
147
181
 
148
182
 
149
183
  <span class="summary_desc"><div class='inline'>
150
- <p>Main method for making decisions.</p>
184
+ <p>Main method for making decisions without a path.</p>
151
185
  </div></span>
152
186
 
153
187
  </li>
@@ -165,7 +199,31 @@
165
199
  <li class="public ">
166
200
  <span class="summary_signature">
167
201
 
168
- <a href="#index_scan-instance_method" title="#index_scan (instance method)">#<strong>index_scan</strong> &#x21d2; Hash{Symbol=&gt;Object} </a>
202
+ <a href="#index_scan_accumulate-instance_method" title="#index_scan_accumulate (instance method)">#<strong>index_scan_accumulate</strong>(scan_cols:, hash:, index_rows:) &#x21d2; Hash{Symbol=&gt;Object} </a>
203
+
204
+
205
+
206
+ </span>
207
+
208
+
209
+
210
+
211
+
212
+
213
+ <span class="private note title">private</span>
214
+
215
+
216
+ <span class="summary_desc"><div class='inline'>
217
+ <p>Scan the index for an accumulated result.</p>
218
+ </div></span>
219
+
220
+ </li>
221
+
222
+
223
+ <li class="public ">
224
+ <span class="summary_signature">
225
+
226
+ <a href="#index_scan_first_match-instance_method" title="#index_scan_first_match (instance method)">#<strong>index_scan_first_match</strong>(scan_cols:, hash:, index_rows:) &#x21d2; Hash{Symbol=&gt;Object} </a>
169
227
 
170
228
 
171
229
 
@@ -180,7 +238,7 @@
180
238
 
181
239
 
182
240
  <span class="summary_desc"><div class='inline'>
183
- <p>Use an index to scan the decision table up against the input hash.</p>
241
+ <p>Scan the index for a first match result.</p>
184
242
  </div></span>
185
243
 
186
244
  </li>
@@ -189,7 +247,7 @@
189
247
  <li class="public ">
190
248
  <span class="summary_signature">
191
249
 
192
- <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(table:, input:) &#x21d2; Decision </a>
250
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(table:) &#x21d2; Decision </a>
193
251
 
194
252
 
195
253
 
@@ -215,7 +273,7 @@
215
273
  <li class="public ">
216
274
  <span class="summary_signature">
217
275
 
218
- <a href="#table_scan-instance_method" title="#table_scan (instance method)">#<strong>table_scan</strong> &#x21d2; Hash{Symbol=&gt;Object} </a>
276
+ <a href="#input-instance_method" title="#input (instance method)">#<strong>input</strong>(data) &#x21d2; void </a>
219
277
 
220
278
 
221
279
 
@@ -230,7 +288,31 @@
230
288
 
231
289
 
232
290
  <span class="summary_desc"><div class='inline'>
233
- <p>Scan the decision table up against the input hash.</p>
291
+ <p>Initialize the input data used to make the decision.</p>
292
+ </div></span>
293
+
294
+ </li>
295
+
296
+
297
+ <li class="public ">
298
+ <span class="summary_signature">
299
+
300
+ <a href="#scan-instance_method" title="#scan (instance method)">#<strong>scan</strong>(data) &#x21d2; Hash{Symbol=&gt;Object} </a>
301
+
302
+
303
+
304
+ </span>
305
+
306
+
307
+
308
+
309
+
310
+
311
+ <span class="private note title">private</span>
312
+
313
+
314
+ <span class="summary_desc"><div class='inline'>
315
+ <p>Scan the decision table and produce an output decision.</p>
234
316
  </div></span>
235
317
 
236
318
  </li>
@@ -245,7 +327,7 @@
245
327
  <div class="method_details first">
246
328
  <h3 class="signature first" id="initialize-instance_method">
247
329
 
248
- #<strong>initialize</strong>(table:, input:) &#x21d2; <tt><span class='object_link'><a href="" title="CSVDecision::Decision (class)">Decision</a></span></tt>
330
+ #<strong>initialize</strong>(table:) &#x21d2; <tt><span class='object_link'><a href="" title="CSVDecision::Decision (class)">Decision</a></span></tt>
249
331
 
250
332
 
251
333
 
@@ -279,22 +361,6 @@
279
361
  &mdash;
280
362
  <div class='inline'>
281
363
  <p>Decision table being processed.</p>
282
- </div>
283
-
284
- </li>
285
-
286
- <li>
287
-
288
- <span class='name'>input</span>
289
-
290
-
291
- <span class='type'>(<tt>Hash{Symbol=&gt;Object}</tt>)</span>
292
-
293
-
294
-
295
- &mdash;
296
- <div class='inline'>
297
- <p>Input hash data structure.</p>
298
364
  </div>
299
365
 
300
366
  </li>
@@ -308,37 +374,23 @@
308
374
  <pre class="lines">
309
375
 
310
376
 
377
+ 31
311
378
  32
312
379
  33
313
380
  34
314
381
  35
315
382
  36
316
- 37
317
- 38
318
- 39
319
- 40
320
- 41
321
- 42
322
- 43
323
- 44
324
- 45</pre>
383
+ 37</pre>
325
384
  </td>
326
385
  <td>
327
- <pre class="code"><span class="info file"># File 'lib/csv_decision/decision.rb', line 32</span>
386
+ <pre class="code"><span class="info file"># File 'lib/csv_decision/decision.rb', line 31</span>
328
387
 
329
- <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='label'>table:</span><span class='comma'>,</span> <span class='label'>input:</span><span class='rparen'>)</span>
388
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='label'>table:</span><span class='rparen'>)</span>
330
389
  <span class='comment'># The result object is a hash of values, and each value will be an array if this is
331
390
  </span> <span class='comment'># a multi-row result for the +first_match: false+ option.
332
- </span> <span class='ivar'>@result</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Result.html" title="CSVDecision::Result (class)">Result</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Result.html#initialize-instance_method" title="CSVDecision::Result#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='label'>table:</span> <span class='id identifier rubyid_table'>table</span><span class='comma'>,</span> <span class='label'>input:</span> <span class='id identifier rubyid_input'>input</span><span class='lbracket'>[</span><span class='symbol'>:hash</span><span class='rbracket'>]</span><span class='rparen'>)</span>
333
-
334
- <span class='comment'># All rows picked by the matching process. An array if +first_match: false+,
335
- </span> <span class='comment'># otherwise a single row.
336
- </span> <span class='ivar'>@rows_picked</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
337
-
391
+ </span> <span class='ivar'>@result</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Result.html" title="CSVDecision::Result (class)">Result</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Result.html#initialize-instance_method" title="CSVDecision::Result#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='label'>table:</span> <span class='id identifier rubyid_table'>table</span><span class='rparen'>)</span>
338
392
  <span class='ivar'>@first_match</span> <span class='op'>=</span> <span class='id identifier rubyid_table'>table</span><span class='period'>.</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:first_match</span><span class='rbracket'>]</span>
339
-
340
393
  <span class='ivar'>@table</span> <span class='op'>=</span> <span class='id identifier rubyid_table'>table</span>
341
- <span class='ivar'>@input</span> <span class='op'>=</span> <span class='id identifier rubyid_input'>input</span>
342
394
  <span class='kw'>end</span></pre>
343
395
  </td>
344
396
  </tr>
@@ -347,6 +399,76 @@
347
399
 
348
400
  </div>
349
401
 
402
+ <div id="instance_attr_details" class="attr_details">
403
+ <h2>Instance Attribute Details</h2>
404
+
405
+
406
+ <span id=""></span>
407
+ <div class="method_details first">
408
+ <h3 class="signature first" id="first_match-instance_method">
409
+
410
+ #<strong>first_match</strong> &#x21d2; <tt>Boolean</tt> <span class="extras">(readonly)</span>
411
+
412
+
413
+
414
+
415
+
416
+ </h3><div class="docstring">
417
+ <div class="discussion">
418
+ <p class="note private">
419
+ <strong>This method is part of a private API.</strong>
420
+ You should avoid using this method if possible, as it may be removed or be changed in the future.
421
+ </p>
422
+
423
+ <p>Returns True if a first match decision table.</p>
424
+
425
+
426
+ </div>
427
+ </div>
428
+ <div class="tags">
429
+
430
+ <p class="tag_title">Returns:</p>
431
+ <ul class="return">
432
+
433
+ <li>
434
+
435
+
436
+ <span class='type'>(<tt>Boolean</tt>)</span>
437
+
438
+
439
+
440
+ &mdash;
441
+ <div class='inline'>
442
+ <p>True if a first match decision table.</p>
443
+ </div>
444
+
445
+ </li>
446
+
447
+ </ul>
448
+
449
+ </div><table class="source_code">
450
+ <tr>
451
+ <td>
452
+ <pre class="lines">
453
+
454
+
455
+ 28
456
+ 29
457
+ 30</pre>
458
+ </td>
459
+ <td>
460
+ <pre class="code"><span class="info file"># File 'lib/csv_decision/decision.rb', line 28</span>
461
+
462
+ <span class='kw'>def</span> <span class='id identifier rubyid_first_match'>first_match</span>
463
+ <span class='ivar'>@first_match</span>
464
+ <span class='kw'>end</span></pre>
465
+ </td>
466
+ </tr>
467
+ </table>
468
+ </div>
469
+
470
+ </div>
471
+
350
472
 
351
473
  <div id="class_method_details" class="method_details_list">
352
474
  <h2>Class Method Details</h2>
@@ -368,7 +490,7 @@
368
490
  You should avoid using this method if possible, as it may be removed or be changed in the future.
369
491
  </p>
370
492
 
371
- <p>Main method for making decisions.</p>
493
+ <p>Main method for making decisions without a path.</p>
372
494
 
373
495
 
374
496
  </div>
@@ -460,24 +582,18 @@ hash. Otherwise a copy of the input hash is symbolized.</p>
460
582
  22
461
583
  23
462
584
  24
463
- 25
464
- 26
465
- 27
466
- 28</pre>
585
+ 25</pre>
467
586
  </td>
468
587
  <td>
469
588
  <pre class="code"><span class="info file"># File 'lib/csv_decision/decision.rb', line 18</span>
470
589
 
471
590
  <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_make'>make</span><span class='lparen'>(</span><span class='label'>table:</span><span class='comma'>,</span> <span class='label'>input:</span><span class='comma'>,</span> <span class='label'>symbolize_keys:</span><span class='rparen'>)</span>
472
591
  <span class='comment'># Parse and transform the hash supplied as input
473
- </span> <span class='id identifier rubyid_input'>input</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Input.html" title="CSVDecision::Input (module)">Input</a></span></span><span class='period'>.</span><span class='id identifier rubyid_parse'><span class='object_link'><a href="Input.html#parse-class_method" title="CSVDecision::Input.parse (method)">parse</a></span></span><span class='lparen'>(</span><span class='label'>table:</span> <span class='id identifier rubyid_table'>table</span><span class='comma'>,</span> <span class='label'>input:</span> <span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='label'>symbolize_keys:</span> <span class='id identifier rubyid_symbolize_keys'>symbolize_keys</span><span class='rparen'>)</span>
592
+ </span> <span class='id identifier rubyid_data'>data</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Input.html" title="CSVDecision::Input (module)">Input</a></span></span><span class='period'>.</span><span class='id identifier rubyid_parse'><span class='object_link'><a href="Input.html#parse-class_method" title="CSVDecision::Input.parse (method)">parse</a></span></span><span class='lparen'>(</span><span class='label'>table:</span> <span class='id identifier rubyid_table'>table</span><span class='comma'>,</span> <span class='label'>input:</span> <span class='id identifier rubyid_input'>input</span><span class='comma'>,</span> <span class='label'>symbolize_keys:</span> <span class='id identifier rubyid_symbolize_keys'>symbolize_keys</span><span class='rparen'>)</span>
474
593
 
475
594
  <span class='comment'># The decision object collects the results of the search and
476
- </span> <span class='comment'># calculates the final result
477
- </span> <span class='id identifier rubyid_decision'>decision</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="" title="CSVDecision::Decision (class)">Decision</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="#initialize-instance_method" title="CSVDecision::Decision#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='label'>table:</span> <span class='id identifier rubyid_table'>table</span><span class='comma'>,</span> <span class='label'>input:</span> <span class='id identifier rubyid_input'>input</span><span class='rparen'>)</span>
478
-
479
- <span class='comment'># Use the table&#39;s index if present
480
- </span> <span class='id identifier rubyid_table'>table</span><span class='period'>.</span><span class='id identifier rubyid_index'>index</span> <span class='op'>?</span> <span class='id identifier rubyid_decision'>decision</span><span class='period'>.</span><span class='id identifier rubyid_index_scan'>index_scan</span> <span class='op'>:</span> <span class='id identifier rubyid_decision'>decision</span><span class='period'>.</span><span class='id identifier rubyid_table_scan'>table_scan</span>
595
+ </span> <span class='comment'># calculates the final result.
596
+ </span> <span class='const'><span class='object_link'><a href="" title="CSVDecision::Decision (class)">Decision</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="#initialize-instance_method" title="CSVDecision::Decision#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='label'>table:</span> <span class='id identifier rubyid_table'>table</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_scan'><span class='object_link'><a href="#scan-instance_method" title="CSVDecision::Decision#scan (method)">scan</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span>
481
597
  <span class='kw'>end</span></pre>
482
598
  </td>
483
599
  </tr>
@@ -491,9 +607,9 @@ hash. Otherwise a copy of the input hash is symbolized.</p>
491
607
 
492
608
 
493
609
  <div class="method_details first">
494
- <h3 class="signature first" id="index_scan-instance_method">
610
+ <h3 class="signature first" id="index_scan_accumulate-instance_method">
495
611
 
496
- #<strong>index_scan</strong> &#x21d2; <tt>Hash{Symbol=&gt;Object}</tt>
612
+ #<strong>index_scan_accumulate</strong>(scan_cols:, hash:, index_rows:) &#x21d2; <tt>Hash{Symbol=&gt;Object}</tt>
497
613
 
498
614
 
499
615
 
@@ -506,13 +622,50 @@ hash. Otherwise a copy of the input hash is symbolized.</p>
506
622
  You should avoid using this method if possible, as it may be removed or be changed in the future.
507
623
  </p>
508
624
 
509
- <p>Use an index to scan the decision table up against the input hash.</p>
625
+ <p>Scan the index for an accumulated result.</p>
510
626
 
511
627
 
512
628
  </div>
513
629
  </div>
514
630
  <div class="tags">
631
+ <p class="tag_title">Parameters:</p>
632
+ <ul class="param">
633
+
634
+ <li>
635
+
636
+ <span class='name'>scan_cols</span>
637
+
638
+
639
+ <span class='type'>(<tt>Hash{Integer=&gt;Object}</tt>)</span>
640
+
641
+
642
+
643
+ </li>
644
+
645
+ <li>
646
+
647
+ <span class='name'>hash</span>
648
+
649
+
650
+ <span class='type'>(<tt>Hash{Symbol=&gt;Object}</tt>)</span>
651
+
652
+
653
+
654
+ </li>
655
+
656
+ <li>
657
+
658
+ <span class='name'>index_rows</span>
659
+
660
+
661
+ <span class='type'>(<tt>Array&lt;Integer&gt;</tt>)</span>
662
+
663
+
664
+
665
+ </li>
515
666
 
667
+ </ul>
668
+
516
669
  <p class="tag_title">Returns:</p>
517
670
  <ul class="return">
518
671
 
@@ -523,10 +676,120 @@ hash. Otherwise a copy of the input hash is symbolized.</p>
523
676
 
524
677
 
525
678
 
526
- &mdash;
527
- <div class='inline'>
528
- <p>Decision result.</p>
679
+ </li>
680
+
681
+ </ul>
682
+
683
+ </div><table class="source_code">
684
+ <tr>
685
+ <td>
686
+ <pre class="lines">
687
+
688
+
689
+ 87
690
+ 88
691
+ 89
692
+ 90
693
+ 91
694
+ 92
695
+ 93
696
+ 94
697
+ 95
698
+ 96
699
+ 97
700
+ 98
701
+ 99</pre>
702
+ </td>
703
+ <td>
704
+ <pre class="code"><span class="info file"># File 'lib/csv_decision/decision.rb', line 87</span>
705
+
706
+ <span class='kw'>def</span> <span class='id identifier rubyid_index_scan_accumulate'>index_scan_accumulate</span><span class='lparen'>(</span><span class='label'>scan_cols:</span><span class='comma'>,</span> <span class='label'>hash:</span><span class='comma'>,</span> <span class='label'>index_rows:</span><span class='rparen'>)</span>
707
+ <span class='id identifier rubyid_index_rows'>index_rows</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_start_row'>start_row</span><span class='comma'>,</span> <span class='id identifier rubyid_end_row'>end_row</span><span class='op'>|</span>
708
+ <span class='ivar'>@table</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='id identifier rubyid_start_row'>start_row</span><span class='comma'>,</span> <span class='id identifier rubyid_end_row'>end_row</span> <span class='op'>||</span> <span class='id identifier rubyid_start_row'>start_row</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_row'>row</span><span class='comma'>,</span> <span class='id identifier rubyid_index'>index</span><span class='op'>|</span>
709
+ <span class='kw'>next</span> <span class='kw'>unless</span> <span class='ivar'>@table</span><span class='period'>.</span><span class='id identifier rubyid_scan_rows'>scan_rows</span><span class='lbracket'>[</span><span class='id identifier rubyid_index'>index</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_match?'>match?</span><span class='lparen'>(</span><span class='label'>row:</span> <span class='id identifier rubyid_row'>row</span><span class='comma'>,</span> <span class='label'>hash:</span> <span class='id identifier rubyid_hash'>hash</span><span class='comma'>,</span> <span class='label'>scan_cols:</span> <span class='id identifier rubyid_scan_cols'>scan_cols</span><span class='rparen'>)</span>
710
+
711
+ <span class='comment'># Accumulate output rows.
712
+ </span> <span class='ivar'>@rows_picked</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_row'>row</span>
713
+ <span class='ivar'>@result</span><span class='period'>.</span><span class='id identifier rubyid_accumulate_outs'>accumulate_outs</span><span class='lparen'>(</span><span class='id identifier rubyid_row'>row</span><span class='rparen'>)</span>
714
+ <span class='kw'>end</span>
715
+ <span class='kw'>end</span>
716
+
717
+ <span class='ivar'>@rows_picked</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='lbrace'>{</span><span class='rbrace'>}</span> <span class='op'>:</span> <span class='id identifier rubyid_accumulated_result'>accumulated_result</span>
718
+ <span class='kw'>end</span></pre>
719
+ </td>
720
+ </tr>
721
+ </table>
722
+ </div>
723
+
724
+ <div class="method_details ">
725
+ <h3 class="signature " id="index_scan_first_match-instance_method">
726
+
727
+ #<strong>index_scan_first_match</strong>(scan_cols:, hash:, index_rows:) &#x21d2; <tt>Hash{Symbol=&gt;Object}</tt>
728
+
729
+
730
+
731
+
732
+
733
+ </h3><div class="docstring">
734
+ <div class="discussion">
735
+ <p class="note private">
736
+ <strong>This method is part of a private API.</strong>
737
+ You should avoid using this method if possible, as it may be removed or be changed in the future.
738
+ </p>
739
+
740
+ <p>Scan the index for a first match result.</p>
741
+
742
+
743
+ </div>
529
744
  </div>
745
+ <div class="tags">
746
+ <p class="tag_title">Parameters:</p>
747
+ <ul class="param">
748
+
749
+ <li>
750
+
751
+ <span class='name'>scan_cols</span>
752
+
753
+
754
+ <span class='type'>(<tt>Hash{Integer=&gt;Object}</tt>)</span>
755
+
756
+
757
+
758
+ </li>
759
+
760
+ <li>
761
+
762
+ <span class='name'>hash</span>
763
+
764
+
765
+ <span class='type'>(<tt>Hash{Symbol=&gt;Object}</tt>)</span>
766
+
767
+
768
+
769
+ </li>
770
+
771
+ <li>
772
+
773
+ <span class='name'>index_rows</span>
774
+
775
+
776
+ <span class='type'>(<tt>Array&lt;Integer&gt;</tt>)</span>
777
+
778
+
779
+
780
+ </li>
781
+
782
+ </ul>
783
+
784
+ <p class="tag_title">Returns:</p>
785
+ <ul class="return">
786
+
787
+ <li>
788
+
789
+
790
+ <span class='type'>(<tt>Hash{Symbol=&gt;Object}</tt>)</span>
791
+
792
+
530
793
 
531
794
  </li>
532
795
 
@@ -538,11 +801,6 @@ hash. Otherwise a copy of the input hash is symbolized.</p>
538
801
  <pre class="lines">
539
802
 
540
803
 
541
- 64
542
- 65
543
- 66
544
- 67
545
- 68
546
804
  69
547
805
  70
548
806
  71
@@ -550,23 +808,24 @@ hash. Otherwise a copy of the input hash is symbolized.</p>
550
808
  73
551
809
  74
552
810
  75
553
- 76</pre>
811
+ 76
812
+ 77
813
+ 78
814
+ 79</pre>
554
815
  </td>
555
816
  <td>
556
- <pre class="code"><span class="info file"># File 'lib/csv_decision/decision.rb', line 64</span>
557
-
558
- <span class='kw'>def</span> <span class='id identifier rubyid_index_scan'>index_scan</span>
559
- <span class='comment'># If the index lookup fails, there&#39;s no match.
560
- </span> <span class='kw'>return</span> <span class='lbrace'>{</span><span class='rbrace'>}</span> <span class='kw'>unless</span> <span class='lparen'>(</span><span class='id identifier rubyid_index_rows'>index_rows</span> <span class='op'>=</span> <span class='const'>Array</span><span class='lparen'>(</span><span class='ivar'>@table</span><span class='period'>.</span><span class='id identifier rubyid_index'>index</span><span class='period'>.</span><span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='ivar'>@input</span><span class='lbracket'>[</span><span class='symbol'>:key</span><span class='rbracket'>]</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='rparen'>)</span>
817
+ <pre class="code"><span class="info file"># File 'lib/csv_decision/decision.rb', line 69</span>
561
818
 
562
- <span class='id identifier rubyid_hash'>hash</span> <span class='op'>=</span> <span class='ivar'>@input</span><span class='lbracket'>[</span><span class='symbol'>:hash</span><span class='rbracket'>]</span>
563
- <span class='id identifier rubyid_scan_cols'>scan_cols</span> <span class='op'>=</span> <span class='ivar'>@input</span><span class='lbracket'>[</span><span class='symbol'>:scan_cols</span><span class='rbracket'>]</span>
819
+ <span class='kw'>def</span> <span class='id identifier rubyid_index_scan_first_match'>index_scan_first_match</span><span class='lparen'>(</span><span class='label'>scan_cols:</span><span class='comma'>,</span> <span class='label'>hash:</span><span class='comma'>,</span> <span class='label'>index_rows:</span><span class='rparen'>)</span>
820
+ <span class='id identifier rubyid_index_rows'>index_rows</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_start_row'>start_row</span><span class='comma'>,</span> <span class='id identifier rubyid_end_row'>end_row</span><span class='op'>|</span>
821
+ <span class='ivar'>@table</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='id identifier rubyid_start_row'>start_row</span><span class='comma'>,</span> <span class='id identifier rubyid_end_row'>end_row</span> <span class='op'>||</span> <span class='id identifier rubyid_start_row'>start_row</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_row'>row</span><span class='comma'>,</span> <span class='id identifier rubyid_index'>index</span><span class='op'>|</span>
822
+ <span class='kw'>next</span> <span class='kw'>unless</span> <span class='ivar'>@table</span><span class='period'>.</span><span class='id identifier rubyid_scan_rows'>scan_rows</span><span class='lbracket'>[</span><span class='id identifier rubyid_index'>index</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_match?'>match?</span><span class='lparen'>(</span><span class='label'>row:</span> <span class='id identifier rubyid_row'>row</span><span class='comma'>,</span> <span class='label'>hash:</span> <span class='id identifier rubyid_hash'>hash</span><span class='comma'>,</span> <span class='label'>scan_cols:</span> <span class='id identifier rubyid_scan_cols'>scan_cols</span><span class='rparen'>)</span>
564
823
 
565
- <span class='kw'>if</span> <span class='ivar'>@first_match</span>
566
- <span class='id identifier rubyid_index_scan_first_match'>index_scan_first_match</span><span class='lparen'>(</span><span class='label'>scan_cols:</span> <span class='id identifier rubyid_scan_cols'>scan_cols</span><span class='comma'>,</span> <span class='label'>hash:</span> <span class='id identifier rubyid_hash'>hash</span><span class='comma'>,</span> <span class='label'>index_rows:</span> <span class='id identifier rubyid_index_rows'>index_rows</span><span class='rparen'>)</span>
567
- <span class='kw'>else</span>
568
- <span class='id identifier rubyid_index_scan_accumulate'>index_scan_accumulate</span><span class='lparen'>(</span><span class='label'>scan_cols:</span> <span class='id identifier rubyid_scan_cols'>scan_cols</span><span class='comma'>,</span> <span class='label'>hash:</span> <span class='id identifier rubyid_hash'>hash</span><span class='comma'>,</span> <span class='label'>index_rows:</span> <span class='id identifier rubyid_index_rows'>index_rows</span><span class='rparen'>)</span>
824
+ <span class='kw'>return</span> <span class='ivar'>@result</span><span class='period'>.</span><span class='id identifier rubyid_attributes'>attributes</span> <span class='kw'>if</span> <span class='id identifier rubyid_first_match_found'>first_match_found</span><span class='lparen'>(</span><span class='id identifier rubyid_row'>row</span><span class='rparen'>)</span>
825
+ <span class='kw'>end</span>
569
826
  <span class='kw'>end</span>
827
+
828
+ <span class='lbrace'>{</span><span class='rbrace'>}</span>
570
829
  <span class='kw'>end</span></pre>
571
830
  </td>
572
831
  </tr>
@@ -574,9 +833,9 @@ hash. Otherwise a copy of the input hash is symbolized.</p>
574
833
  </div>
575
834
 
576
835
  <div class="method_details ">
577
- <h3 class="signature " id="table_scan-instance_method">
836
+ <h3 class="signature " id="input-instance_method">
578
837
 
579
- #<strong>table_scan</strong> &#x21d2; <tt>Hash{Symbol=&gt;Object}</tt>
838
+ #<strong>input</strong>(data) &#x21d2; <tt>void</tt>
580
839
 
581
840
 
582
841
 
@@ -588,14 +847,111 @@ hash. Otherwise a copy of the input hash is symbolized.</p>
588
847
  <strong>This method is part of a private API.</strong>
589
848
  You should avoid using this method if possible, as it may be removed or be changed in the future.
590
849
  </p>
850
+ <p class="note returns_void">This method returns an undefined value.</p>
851
+ <p>Initialize the input data used to make the decision.</p>
591
852
 
592
- <p>Scan the decision table up against the input hash.</p>
853
+
854
+ </div>
855
+ </div>
856
+ <div class="tags">
857
+ <p class="tag_title">Parameters:</p>
858
+ <ul class="param">
859
+
860
+ <li>
861
+
862
+ <span class='name'>data</span>
863
+
864
+
865
+ <span class='type'>(<tt>Hash{Symbol=&gt;Object}</tt>)</span>
866
+
867
+
868
+
869
+ &mdash;
870
+ <div class='inline'>
871
+ <p>Input hash data structure.</p>
872
+ </div>
873
+
874
+ </li>
875
+
876
+ </ul>
877
+
878
+
879
+ </div><table class="source_code">
880
+ <tr>
881
+ <td>
882
+ <pre class="lines">
883
+
884
+
885
+ 43
886
+ 44
887
+ 45
888
+ 46
889
+ 47
890
+ 48
891
+ 49
892
+ 50
893
+ 51</pre>
894
+ </td>
895
+ <td>
896
+ <pre class="code"><span class="info file"># File 'lib/csv_decision/decision.rb', line 43</span>
897
+
898
+ <span class='kw'>def</span> <span class='id identifier rubyid_input'>input</span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span>
899
+ <span class='ivar'>@result</span><span class='period'>.</span><span class='id identifier rubyid_input'>input</span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='symbol'>:hash</span><span class='rbracket'>]</span><span class='rparen'>)</span>
900
+
901
+ <span class='comment'># All rows picked by the matching process. An array if +first_match: false+,
902
+ </span> <span class='comment'># otherwise a single row.
903
+ </span> <span class='ivar'>@rows_picked</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
904
+
905
+ <span class='ivar'>@input</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span>
906
+ <span class='kw'>end</span></pre>
907
+ </td>
908
+ </tr>
909
+ </table>
910
+ </div>
911
+
912
+ <div class="method_details ">
913
+ <h3 class="signature " id="scan-instance_method">
914
+
915
+ #<strong>scan</strong>(data) &#x21d2; <tt>Hash{Symbol=&gt;Object}</tt>
916
+
917
+
918
+
919
+
920
+
921
+ </h3><div class="docstring">
922
+ <div class="discussion">
923
+ <p class="note private">
924
+ <strong>This method is part of a private API.</strong>
925
+ You should avoid using this method if possible, as it may be removed or be changed in the future.
926
+ </p>
927
+
928
+ <p>Scan the decision table and produce an output decision.</p>
593
929
 
594
930
 
595
931
  </div>
596
932
  </div>
597
933
  <div class="tags">
934
+ <p class="tag_title">Parameters:</p>
935
+ <ul class="param">
936
+
937
+ <li>
938
+
939
+ <span class='name'>data</span>
940
+
941
+
942
+ <span class='type'>(<tt>Hash{Symbol=&gt;Object}</tt>)</span>
943
+
944
+
945
+
946
+ &mdash;
947
+ <div class='inline'>
948
+ <p>Input hash data structure.</p>
949
+ </div>
950
+
951
+ </li>
598
952
 
953
+ </ul>
954
+
599
955
  <p class="tag_title">Returns:</p>
600
956
  <ul class="return">
601
957
 
@@ -621,29 +977,19 @@ hash. Otherwise a copy of the input hash is symbolized.</p>
621
977
  <pre class="lines">
622
978
 
623
979
 
624
- 50
625
- 51
626
- 52
627
- 53
628
- 54
629
- 55
630
- 56
631
980
  57
632
981
  58
633
- 59</pre>
982
+ 59
983
+ 60
984
+ 61</pre>
634
985
  </td>
635
986
  <td>
636
- <pre class="code"><span class="info file"># File 'lib/csv_decision/decision.rb', line 50</span>
637
-
638
- <span class='kw'>def</span> <span class='id identifier rubyid_table_scan'>table_scan</span>
639
- <span class='id identifier rubyid_hash'>hash</span> <span class='op'>=</span> <span class='ivar'>@input</span><span class='lbracket'>[</span><span class='symbol'>:hash</span><span class='rbracket'>]</span>
640
- <span class='id identifier rubyid_scan_cols'>scan_cols</span> <span class='op'>=</span> <span class='ivar'>@input</span><span class='lbracket'>[</span><span class='symbol'>:scan_cols</span><span class='rbracket'>]</span>
987
+ <pre class="code"><span class="info file"># File 'lib/csv_decision/decision.rb', line 57</span>
641
988
 
642
- <span class='kw'>if</span> <span class='ivar'>@first_match</span>
643
- <span class='id identifier rubyid_scan_first_match'>scan_first_match</span><span class='lparen'>(</span><span class='label'>hash:</span> <span class='id identifier rubyid_hash'>hash</span><span class='comma'>,</span> <span class='label'>scan_cols:</span> <span class='id identifier rubyid_scan_cols'>scan_cols</span><span class='rparen'>)</span>
644
- <span class='kw'>else</span>
645
- <span class='id identifier rubyid_scan_accumulate'>scan_accumulate</span><span class='lparen'>(</span><span class='label'>hash:</span> <span class='id identifier rubyid_hash'>hash</span><span class='comma'>,</span> <span class='label'>scan_cols:</span> <span class='id identifier rubyid_scan_cols'>scan_cols</span><span class='rparen'>)</span>
646
- <span class='kw'>end</span>
989
+ <span class='kw'>def</span> <span class='id identifier rubyid_scan'>scan</span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span>
990
+ <span class='id identifier rubyid_input'>input</span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span>
991
+ <span class='comment'># Use the table&#39;s index if present
992
+ </span> <span class='ivar'>@table</span><span class='period'>.</span><span class='id identifier rubyid_index'>index</span> <span class='op'>?</span> <span class='id identifier rubyid_index_scan'>index_scan</span> <span class='op'>:</span> <span class='id identifier rubyid_table_scan'>table_scan</span>
647
993
  <span class='kw'>end</span></pre>
648
994
  </td>
649
995
  </tr>
@@ -655,7 +1001,7 @@ hash. Otherwise a copy of the input hash is symbolized.</p>
655
1001
  </div>
656
1002
 
657
1003
  <div id="footer">
658
- Generated on Sun Jan 28 14:41:49 2018 by
1004
+ Generated on Sun Feb 11 10:26:08 2018 by
659
1005
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
660
1006
  0.9.12 (ruby-2.4.0).
661
1007
  </div>