csv_decision2 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +3 -0
  3. data/.coveralls.yml +2 -0
  4. data/.gitignore +14 -0
  5. data/.rspec +2 -0
  6. data/.rubocop.yml +30 -0
  7. data/.travis.yml +6 -0
  8. data/CHANGELOG.md +85 -0
  9. data/Dockerfile +6 -0
  10. data/Gemfile +7 -0
  11. data/LICENSE +21 -0
  12. data/README.md +356 -0
  13. data/benchmarks/rufus_decision.rb +158 -0
  14. data/csv_decision2.gemspec +38 -0
  15. data/doc/CSVDecision/CellValidationError.html +143 -0
  16. data/doc/CSVDecision/Columns/Default.html +589 -0
  17. data/doc/CSVDecision/Columns/Dictionary.html +801 -0
  18. data/doc/CSVDecision/Columns/Entry.html +508 -0
  19. data/doc/CSVDecision/Columns.html +1259 -0
  20. data/doc/CSVDecision/Constant.html +254 -0
  21. data/doc/CSVDecision/Data.html +479 -0
  22. data/doc/CSVDecision/Decide.html +302 -0
  23. data/doc/CSVDecision/Decision.html +1011 -0
  24. data/doc/CSVDecision/Defaults.html +291 -0
  25. data/doc/CSVDecision/Dictionary/Entry.html +1147 -0
  26. data/doc/CSVDecision/Dictionary.html +426 -0
  27. data/doc/CSVDecision/Error.html +139 -0
  28. data/doc/CSVDecision/FileError.html +143 -0
  29. data/doc/CSVDecision/Function.html +240 -0
  30. data/doc/CSVDecision/Guard.html +245 -0
  31. data/doc/CSVDecision/Header.html +647 -0
  32. data/doc/CSVDecision/Index.html +741 -0
  33. data/doc/CSVDecision/Input.html +404 -0
  34. data/doc/CSVDecision/Load.html +296 -0
  35. data/doc/CSVDecision/Matchers/Constant.html +484 -0
  36. data/doc/CSVDecision/Matchers/Function.html +511 -0
  37. data/doc/CSVDecision/Matchers/Guard.html +503 -0
  38. data/doc/CSVDecision/Matchers/Matcher.html +507 -0
  39. data/doc/CSVDecision/Matchers/Numeric.html +415 -0
  40. data/doc/CSVDecision/Matchers/Pattern.html +491 -0
  41. data/doc/CSVDecision/Matchers/Proc.html +704 -0
  42. data/doc/CSVDecision/Matchers/Range.html +379 -0
  43. data/doc/CSVDecision/Matchers/Symbol.html +426 -0
  44. data/doc/CSVDecision/Matchers.html +1567 -0
  45. data/doc/CSVDecision/Numeric.html +259 -0
  46. data/doc/CSVDecision/Options.html +443 -0
  47. data/doc/CSVDecision/Parse.html +282 -0
  48. data/doc/CSVDecision/Paths.html +742 -0
  49. data/doc/CSVDecision/Result.html +1200 -0
  50. data/doc/CSVDecision/Scan/InputHashes.html +369 -0
  51. data/doc/CSVDecision/Scan.html +313 -0
  52. data/doc/CSVDecision/ScanRow.html +866 -0
  53. data/doc/CSVDecision/Symbol.html +256 -0
  54. data/doc/CSVDecision/Table.html +1470 -0
  55. data/doc/CSVDecision/TableValidationError.html +143 -0
  56. data/doc/CSVDecision/Validate.html +422 -0
  57. data/doc/CSVDecision.html +621 -0
  58. data/doc/_index.html +471 -0
  59. data/doc/class_list.html +51 -0
  60. data/doc/css/common.css +1 -0
  61. data/doc/css/full_list.css +58 -0
  62. data/doc/css/style.css +499 -0
  63. data/doc/file.README.html +421 -0
  64. data/doc/file_list.html +56 -0
  65. data/doc/frames.html +17 -0
  66. data/doc/index.html +421 -0
  67. data/doc/js/app.js +248 -0
  68. data/doc/js/full_list.js +216 -0
  69. data/doc/js/jquery.js +4 -0
  70. data/doc/method_list.html +1163 -0
  71. data/doc/top-level-namespace.html +110 -0
  72. data/docker-compose.yml +13 -0
  73. data/lib/csv_decision/columns.rb +192 -0
  74. data/lib/csv_decision/data.rb +92 -0
  75. data/lib/csv_decision/decision.rb +196 -0
  76. data/lib/csv_decision/defaults.rb +47 -0
  77. data/lib/csv_decision/dictionary.rb +180 -0
  78. data/lib/csv_decision/header.rb +83 -0
  79. data/lib/csv_decision/index.rb +107 -0
  80. data/lib/csv_decision/input.rb +121 -0
  81. data/lib/csv_decision/load.rb +36 -0
  82. data/lib/csv_decision/matchers/constant.rb +74 -0
  83. data/lib/csv_decision/matchers/function.rb +56 -0
  84. data/lib/csv_decision/matchers/guard.rb +142 -0
  85. data/lib/csv_decision/matchers/numeric.rb +44 -0
  86. data/lib/csv_decision/matchers/pattern.rb +94 -0
  87. data/lib/csv_decision/matchers/range.rb +95 -0
  88. data/lib/csv_decision/matchers/symbol.rb +149 -0
  89. data/lib/csv_decision/matchers.rb +220 -0
  90. data/lib/csv_decision/options.rb +124 -0
  91. data/lib/csv_decision/parse.rb +165 -0
  92. data/lib/csv_decision/paths.rb +78 -0
  93. data/lib/csv_decision/result.rb +204 -0
  94. data/lib/csv_decision/scan.rb +117 -0
  95. data/lib/csv_decision/scan_row.rb +142 -0
  96. data/lib/csv_decision/table.rb +101 -0
  97. data/lib/csv_decision/validate.rb +85 -0
  98. data/lib/csv_decision.rb +45 -0
  99. data/spec/csv_decision/columns_spec.rb +251 -0
  100. data/spec/csv_decision/constant_spec.rb +36 -0
  101. data/spec/csv_decision/data_spec.rb +50 -0
  102. data/spec/csv_decision/decision_spec.rb +19 -0
  103. data/spec/csv_decision/examples_spec.rb +242 -0
  104. data/spec/csv_decision/index_spec.rb +58 -0
  105. data/spec/csv_decision/input_spec.rb +55 -0
  106. data/spec/csv_decision/load_spec.rb +28 -0
  107. data/spec/csv_decision/matchers/function_spec.rb +82 -0
  108. data/spec/csv_decision/matchers/guard_spec.rb +170 -0
  109. data/spec/csv_decision/matchers/numeric_spec.rb +47 -0
  110. data/spec/csv_decision/matchers/pattern_spec.rb +183 -0
  111. data/spec/csv_decision/matchers/range_spec.rb +70 -0
  112. data/spec/csv_decision/matchers/symbol_spec.rb +67 -0
  113. data/spec/csv_decision/options_spec.rb +94 -0
  114. data/spec/csv_decision/parse_spec.rb +44 -0
  115. data/spec/csv_decision/table_spec.rb +683 -0
  116. data/spec/csv_decision_spec.rb +7 -0
  117. data/spec/data/invalid/empty.csv +0 -0
  118. data/spec/data/invalid/invalid_header1.csv +4 -0
  119. data/spec/data/invalid/invalid_header2.csv +4 -0
  120. data/spec/data/invalid/invalid_header3.csv +4 -0
  121. data/spec/data/invalid/invalid_header4.csv +4 -0
  122. data/spec/data/valid/benchmark_regexp.csv +10 -0
  123. data/spec/data/valid/index_example.csv +13 -0
  124. data/spec/data/valid/multi_column_index.csv +10 -0
  125. data/spec/data/valid/multi_column_index2.csv +12 -0
  126. data/spec/data/valid/options_in_file1.csv +5 -0
  127. data/spec/data/valid/options_in_file2.csv +5 -0
  128. data/spec/data/valid/options_in_file3.csv +13 -0
  129. data/spec/data/valid/regular_expressions.csv +11 -0
  130. data/spec/data/valid/simple_constants.csv +5 -0
  131. data/spec/data/valid/simple_example.csv +10 -0
  132. data/spec/data/valid/valid.csv +4 -0
  133. data/spec/spec_helper.rb +106 -0
  134. metadata +352 -0
@@ -0,0 +1,1011 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Class: CSVDecision::Decision
8
+
9
+ &mdash; Documentation by YARD 0.9.12
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "CSVDecision::Decision";
19
+ relpath = '../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../_index.html">Index (D)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../CSVDecision.html" title="CSVDecision (module)">CSVDecision</a></span></span>
41
+ &raquo;
42
+ <span class="title">Decision</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Class: CSVDecision::Decision
63
+
64
+
65
+ <span class="private note title">Private</span>
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName">Object</span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">CSVDecision::Decision</li>
78
+
79
+ </ul>
80
+ <a href="#" class="inheritanceTree">show all</a>
81
+
82
+ </dd>
83
+ </dl>
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+ <dl>
96
+ <dt>Defined in:</dt>
97
+ <dd>lib/csv_decision/decision.rb</dd>
98
+ </dl>
99
+
100
+ </div>
101
+
102
+ <h2>Overview</h2><div class="docstring">
103
+ <div class="discussion">
104
+ <p class="note private">
105
+ <strong>This class is part of a private API.</strong>
106
+ You should avoid using this class if possible, as it may be removed or be changed in the future.
107
+ </p>
108
+
109
+ <p>Accumulate the matching row(s) and calculate the final result.</p>
110
+
111
+
112
+ </div>
113
+ </div>
114
+ <div class="tags">
115
+
116
+
117
+ </div>
118
+
119
+
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
+
155
+
156
+
157
+
158
+
159
+ <h2>
160
+ Class Method Summary
161
+ <small><a href="#" class="summary_toggle">collapse</a></small>
162
+ </h2>
163
+
164
+ <ul class="summary">
165
+
166
+ <li class="public ">
167
+ <span class="summary_signature">
168
+
169
+ <a href="#make-class_method" title="make (class method)">.<strong>make</strong>(table:, input:, symbolize_keys:) &#x21d2; Hash{Symbol=&gt;Object} </a>
170
+
171
+
172
+
173
+ </span>
174
+
175
+
176
+
177
+
178
+
179
+
180
+ <span class="private note title">private</span>
181
+
182
+
183
+ <span class="summary_desc"><div class='inline'>
184
+ <p>Main method for making decisions without a path.</p>
185
+ </div></span>
186
+
187
+ </li>
188
+
189
+
190
+ </ul>
191
+
192
+ <h2>
193
+ Instance Method Summary
194
+ <small><a href="#" class="summary_toggle">collapse</a></small>
195
+ </h2>
196
+
197
+ <ul class="summary">
198
+
199
+ <li class="public ">
200
+ <span class="summary_signature">
201
+
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>
227
+
228
+
229
+
230
+ </span>
231
+
232
+
233
+
234
+
235
+
236
+
237
+ <span class="private note title">private</span>
238
+
239
+
240
+ <span class="summary_desc"><div class='inline'>
241
+ <p>Scan the index for a first match result.</p>
242
+ </div></span>
243
+
244
+ </li>
245
+
246
+
247
+ <li class="public ">
248
+ <span class="summary_signature">
249
+
250
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(table:) &#x21d2; Decision </a>
251
+
252
+
253
+
254
+ </span>
255
+
256
+
257
+ <span class="note title constructor">constructor</span>
258
+
259
+
260
+
261
+
262
+
263
+ <span class="private note title">private</span>
264
+
265
+
266
+ <span class="summary_desc"><div class='inline'>
267
+ <p>A new instance of Decision.</p>
268
+ </div></span>
269
+
270
+ </li>
271
+
272
+
273
+ <li class="public ">
274
+ <span class="summary_signature">
275
+
276
+ <a href="#input-instance_method" title="#input (instance method)">#<strong>input</strong>(data) &#x21d2; void </a>
277
+
278
+
279
+
280
+ </span>
281
+
282
+
283
+
284
+
285
+
286
+
287
+ <span class="private note title">private</span>
288
+
289
+
290
+ <span class="summary_desc"><div class='inline'>
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>
316
+ </div></span>
317
+
318
+ </li>
319
+
320
+
321
+ </ul>
322
+
323
+
324
+ <div id="constructor_details" class="method_details_list">
325
+ <h2>Constructor Details</h2>
326
+
327
+ <div class="method_details first">
328
+ <h3 class="signature first" id="initialize-instance_method">
329
+
330
+ #<strong>initialize</strong>(table:) &#x21d2; <tt><span class='object_link'><a href="" title="CSVDecision::Decision (class)">Decision</a></span></tt>
331
+
332
+
333
+
334
+
335
+
336
+ </h3><div class="docstring">
337
+ <div class="discussion">
338
+ <p class="note private">
339
+ <strong>This method is part of a private API.</strong>
340
+ You should avoid using this method if possible, as it may be removed or be changed in the future.
341
+ </p>
342
+
343
+ <p>Returns a new instance of Decision</p>
344
+
345
+
346
+ </div>
347
+ </div>
348
+ <div class="tags">
349
+ <p class="tag_title">Parameters:</p>
350
+ <ul class="param">
351
+
352
+ <li>
353
+
354
+ <span class='name'>table</span>
355
+
356
+
357
+ <span class='type'>(<tt><span class='object_link'><a href="Table.html" title="CSVDecision::Table (class)">CSVDecision::Table</a></span></tt>)</span>
358
+
359
+
360
+
361
+ &mdash;
362
+ <div class='inline'>
363
+ <p>Decision table being processed.</p>
364
+ </div>
365
+
366
+ </li>
367
+
368
+ </ul>
369
+
370
+
371
+ </div><table class="source_code">
372
+ <tr>
373
+ <td>
374
+ <pre class="lines">
375
+
376
+
377
+ 31
378
+ 32
379
+ 33
380
+ 34
381
+ 35
382
+ 36
383
+ 37</pre>
384
+ </td>
385
+ <td>
386
+ <pre class="code"><span class="info file"># File 'lib/csv_decision/decision.rb', line 31</span>
387
+
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>
389
+ <span class='comment'># The result object is a hash of values, and each value will be an array if this is
390
+ </span> <span class='comment'># a multi-row result for the +first_match: false+ option.
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>
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>
393
+ <span class='ivar'>@table</span> <span class='op'>=</span> <span class='id identifier rubyid_table'>table</span>
394
+ <span class='kw'>end</span></pre>
395
+ </td>
396
+ </tr>
397
+ </table>
398
+ </div>
399
+
400
+ </div>
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
+
472
+
473
+ <div id="class_method_details" class="method_details_list">
474
+ <h2>Class Method Details</h2>
475
+
476
+
477
+ <div class="method_details first">
478
+ <h3 class="signature first" id="make-class_method">
479
+
480
+ .<strong>make</strong>(table:, input:, symbolize_keys:) &#x21d2; <tt>Hash{Symbol=&gt;Object}</tt>
481
+
482
+
483
+
484
+
485
+
486
+ </h3><div class="docstring">
487
+ <div class="discussion">
488
+ <p class="note private">
489
+ <strong>This method is part of a private API.</strong>
490
+ You should avoid using this method if possible, as it may be removed or be changed in the future.
491
+ </p>
492
+
493
+ <p>Main method for making decisions without a path.</p>
494
+
495
+
496
+ </div>
497
+ </div>
498
+ <div class="tags">
499
+ <p class="tag_title">Parameters:</p>
500
+ <ul class="param">
501
+
502
+ <li>
503
+
504
+ <span class='name'>table</span>
505
+
506
+
507
+ <span class='type'>(<tt><span class='object_link'><a href="Table.html" title="CSVDecision::Table (class)">CSVDecision::Table</a></span></tt>)</span>
508
+
509
+
510
+
511
+ &mdash;
512
+ <div class='inline'>
513
+ <p>Decision table.</p>
514
+ </div>
515
+
516
+ </li>
517
+
518
+ <li>
519
+
520
+ <span class='name'>input</span>
521
+
522
+
523
+ <span class='type'>(<tt>Hash</tt>)</span>
524
+
525
+
526
+
527
+ &mdash;
528
+ <div class='inline'>
529
+ <p>Input hash (keys may or may not be symbolized)</p>
530
+ </div>
531
+
532
+ </li>
533
+
534
+ <li>
535
+
536
+ <span class='name'>symbolize_keys</span>
537
+
538
+
539
+ <span class='type'>(<tt>Boolean</tt>)</span>
540
+
541
+
542
+
543
+ &mdash;
544
+ <div class='inline'>
545
+ <p>Set to false if keys are symbolized and it&#39;s OK to mutate the input
546
+ hash. Otherwise a copy of the input hash is symbolized.</p>
547
+ </div>
548
+
549
+ </li>
550
+
551
+ </ul>
552
+
553
+ <p class="tag_title">Returns:</p>
554
+ <ul class="return">
555
+
556
+ <li>
557
+
558
+
559
+ <span class='type'>(<tt>Hash{Symbol=&gt;Object}</tt>)</span>
560
+
561
+
562
+
563
+ &mdash;
564
+ <div class='inline'>
565
+ <p>Decision result.</p>
566
+ </div>
567
+
568
+ </li>
569
+
570
+ </ul>
571
+
572
+ </div><table class="source_code">
573
+ <tr>
574
+ <td>
575
+ <pre class="lines">
576
+
577
+
578
+ 18
579
+ 19
580
+ 20
581
+ 21
582
+ 22
583
+ 23
584
+ 24
585
+ 25</pre>
586
+ </td>
587
+ <td>
588
+ <pre class="code"><span class="info file"># File 'lib/csv_decision/decision.rb', line 18</span>
589
+
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>
591
+ <span class='comment'># Parse and transform the hash supplied as input
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>
593
+
594
+ <span class='comment'># The decision object collects the results of the search and
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>
597
+ <span class='kw'>end</span></pre>
598
+ </td>
599
+ </tr>
600
+ </table>
601
+ </div>
602
+
603
+ </div>
604
+
605
+ <div id="instance_method_details" class="method_details_list">
606
+ <h2>Instance Method Details</h2>
607
+
608
+
609
+ <div class="method_details first">
610
+ <h3 class="signature first" id="index_scan_accumulate-instance_method">
611
+
612
+ #<strong>index_scan_accumulate</strong>(scan_cols:, hash:, index_rows:) &#x21d2; <tt>Hash{Symbol=&gt;Object}</tt>
613
+
614
+
615
+
616
+
617
+
618
+ </h3><div class="docstring">
619
+ <div class="discussion">
620
+ <p class="note private">
621
+ <strong>This method is part of a private API.</strong>
622
+ You should avoid using this method if possible, as it may be removed or be changed in the future.
623
+ </p>
624
+
625
+ <p>Scan the index for an accumulated result.</p>
626
+
627
+
628
+ </div>
629
+ </div>
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>
666
+
667
+ </ul>
668
+
669
+ <p class="tag_title">Returns:</p>
670
+ <ul class="return">
671
+
672
+ <li>
673
+
674
+
675
+ <span class='type'>(<tt>Hash{Symbol=&gt;Object}</tt>)</span>
676
+
677
+
678
+
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>
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
+
793
+
794
+ </li>
795
+
796
+ </ul>
797
+
798
+ </div><table class="source_code">
799
+ <tr>
800
+ <td>
801
+ <pre class="lines">
802
+
803
+
804
+ 69
805
+ 70
806
+ 71
807
+ 72
808
+ 73
809
+ 74
810
+ 75
811
+ 76
812
+ 77
813
+ 78
814
+ 79</pre>
815
+ </td>
816
+ <td>
817
+ <pre class="code"><span class="info file"># File 'lib/csv_decision/decision.rb', line 69</span>
818
+
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>
823
+
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>
826
+ <span class='kw'>end</span>
827
+
828
+ <span class='lbrace'>{</span><span class='rbrace'>}</span>
829
+ <span class='kw'>end</span></pre>
830
+ </td>
831
+ </tr>
832
+ </table>
833
+ </div>
834
+
835
+ <div class="method_details ">
836
+ <h3 class="signature " id="input-instance_method">
837
+
838
+ #<strong>input</strong>(data) &#x21d2; <tt>void</tt>
839
+
840
+
841
+
842
+
843
+
844
+ </h3><div class="docstring">
845
+ <div class="discussion">
846
+ <p class="note private">
847
+ <strong>This method is part of a private API.</strong>
848
+ You should avoid using this method if possible, as it may be removed or be changed in the future.
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>
852
+
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>
929
+
930
+
931
+ </div>
932
+ </div>
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>
952
+
953
+ </ul>
954
+
955
+ <p class="tag_title">Returns:</p>
956
+ <ul class="return">
957
+
958
+ <li>
959
+
960
+
961
+ <span class='type'>(<tt>Hash{Symbol=&gt;Object}</tt>)</span>
962
+
963
+
964
+
965
+ &mdash;
966
+ <div class='inline'>
967
+ <p>Decision result.</p>
968
+ </div>
969
+
970
+ </li>
971
+
972
+ </ul>
973
+
974
+ </div><table class="source_code">
975
+ <tr>
976
+ <td>
977
+ <pre class="lines">
978
+
979
+
980
+ 57
981
+ 58
982
+ 59
983
+ 60
984
+ 61</pre>
985
+ </td>
986
+ <td>
987
+ <pre class="code"><span class="info file"># File 'lib/csv_decision/decision.rb', line 57</span>
988
+
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>
993
+ <span class='kw'>end</span></pre>
994
+ </td>
995
+ </tr>
996
+ </table>
997
+ </div>
998
+
999
+ </div>
1000
+
1001
+ </div>
1002
+
1003
+ <div id="footer">
1004
+ Generated on Sun Feb 11 10:26:08 2018 by
1005
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1006
+ 0.9.12 (ruby-2.4.0).
1007
+ </div>
1008
+
1009
+ </div>
1010
+ </body>
1011
+ </html>