csv_decision 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +4 -0
- data/README.md +62 -28
- data/csv_decision.gemspec +1 -1
- data/doc/CSVDecision/CellValidationError.html +2 -2
- data/doc/CSVDecision/Columns/Dictionary.html +114 -20
- data/doc/CSVDecision/Columns/Entry.html +2 -2
- data/doc/CSVDecision/Columns.html +109 -27
- data/doc/CSVDecision/Data.html +2 -2
- data/doc/CSVDecision/Decide.html +2 -2
- data/doc/CSVDecision/Decision.html +21 -21
- data/doc/CSVDecision/Dictionary/Entry.html +508 -0
- data/doc/CSVDecision/Dictionary.html +265 -0
- data/doc/CSVDecision/Error.html +2 -2
- data/doc/CSVDecision/FileError.html +3 -3
- data/doc/CSVDecision/Header.html +37 -136
- data/doc/CSVDecision/Input.html +2 -2
- data/doc/CSVDecision/Load.html +2 -2
- data/doc/CSVDecision/Matchers/Constant.html +2 -2
- data/doc/CSVDecision/Matchers/Function.html +2 -2
- data/doc/CSVDecision/Matchers/Guard.html +92 -25
- data/doc/CSVDecision/Matchers/Matcher.html +14 -18
- data/doc/CSVDecision/Matchers/Numeric.html +2 -2
- data/doc/CSVDecision/Matchers/Pattern.html +2 -2
- data/doc/CSVDecision/Matchers/Range.html +2 -2
- data/doc/CSVDecision/Matchers/Symbol.html +2 -2
- data/doc/CSVDecision/Matchers.html +5 -5
- data/doc/CSVDecision/Options.html +2 -2
- data/doc/CSVDecision/Parse.html +6 -4
- data/doc/CSVDecision/Result.html +944 -0
- data/doc/CSVDecision/ScanRow.html +70 -80
- data/doc/CSVDecision/Table.html +134 -54
- data/doc/CSVDecision.html +5 -5
- data/doc/_index.html +18 -4
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +132 -62
- data/doc/index.html +132 -62
- data/doc/method_list.html +156 -60
- data/doc/top-level-namespace.html +2 -2
- data/lib/csv_decision/columns.rb +1 -8
- data/lib/csv_decision/decision.rb +45 -96
- data/lib/csv_decision/dictionary.rb +149 -0
- data/lib/csv_decision/header.rb +6 -133
- data/lib/csv_decision/matchers.rb +1 -2
- data/lib/csv_decision/parse.rb +18 -7
- data/lib/csv_decision/result.rb +180 -0
- data/lib/csv_decision/scan_row.rb +13 -7
- data/lib/csv_decision/table.rb +6 -5
- data/lib/csv_decision.rb +3 -1
- data/spec/csv_decision/columns_spec.rb +25 -4
- data/spec/csv_decision/examples_spec.rb +25 -0
- data/spec/csv_decision/matchers/guard_spec.rb +26 -9
- data/spec/csv_decision/table_spec.rb +48 -2
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c0f396c58ab937ab442debbcde0d2944ac13599
|
4
|
+
data.tar.gz: '07088b2d4829a8ff1eb64a1fa8806158657e631f'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d591ec2a8bdeaa0d6ca62c1f8e650195cf612443c9a0171d8c1d0664dace315a1a71da98255ea2eee5cb10595b135fb56edfeed4e7e932002669a13dc3a5b41b
|
7
|
+
data.tar.gz: 7ca7a57e7bc0bd0ff5dc8a5cf3b50da224efa2ff45e49d6f92ffcd41103c81489d787828380cb76f208465d6c414095a1ee7fc9ef787b222e18d9a96df9555a5
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -9,7 +9,7 @@ CSV Decision
|
|
9
9
|
|
10
10
|
### CSV based Ruby decision tables
|
11
11
|
|
12
|
-
`csv_decision` is a RubyGem for CSV
|
12
|
+
`csv_decision` is a RubyGem for CSV based
|
13
13
|
[decision tables](https://en.wikipedia.org/wiki/Decision_table).
|
14
14
|
It accepts decision tables implemented as a
|
15
15
|
[CSV file](https://en.wikipedia.org/wiki/Comma-separated_values),
|
@@ -18,7 +18,7 @@ producing a decision as an output hash.
|
|
18
18
|
|
19
19
|
### Why use `csv_decision`?
|
20
20
|
|
21
|
-
Typical "business logic" is notoriously illogical
|
21
|
+
Typical "business logic" is notoriously illogical - full of corner cases and one-off
|
22
22
|
exceptions.
|
23
23
|
A decision table can express data-based decisions in a way that comes more naturally
|
24
24
|
to subject matter experts, who typically prefer spreadsheet models.
|
@@ -46,22 +46,22 @@ To get started, just add `csv_decision` to your `Gemfile`, and then run `bundle`
|
|
46
46
|
|
47
47
|
### Simple example
|
48
48
|
|
49
|
-
This table considers two input conditions: `topic` and `region
|
50
|
-
|
51
|
-
labeled `out
|
49
|
+
This table considers two input conditions: `topic` and `region`, labeled `in:`.
|
50
|
+
Certain combinations yield an output value for `team_member`,
|
51
|
+
labeled `out:`.
|
52
52
|
|
53
53
|
```
|
54
|
-
in
|
55
|
-
|
56
|
-
sports
|
57
|
-
sports
|
58
|
-
finance
|
59
|
-
finance
|
60
|
-
finance
|
61
|
-
politics
|
62
|
-
politics
|
63
|
-
politics
|
64
|
-
|
54
|
+
in:topic | in:region | out:team_member
|
55
|
+
---------+------------+----------------
|
56
|
+
sports | Europe | Alice
|
57
|
+
sports | | Bob
|
58
|
+
finance | America | Charlie
|
59
|
+
finance | Europe | Donald
|
60
|
+
finance | | Ernest
|
61
|
+
politics | Asia | Fujio
|
62
|
+
politics | America | Gilbert
|
63
|
+
politics | | Henry
|
64
|
+
| | Zach
|
65
65
|
```
|
66
66
|
|
67
67
|
When the topic is `finance` and the region is `Europe` the team member `Donald`
|
@@ -99,7 +99,10 @@ Here is the example as code:
|
|
99
99
|
table.decide(topic: 'culture', region: 'America') #=> { team_member: 'Zach' }
|
100
100
|
```
|
101
101
|
|
102
|
-
An empty `in
|
102
|
+
An empty `in:` cell means "matches any value", even nils.
|
103
|
+
|
104
|
+
Note that all column header names are symbolized, so it's actually more accurate to write
|
105
|
+
`in :topic`; however spaces before and after the `:` do not matter.
|
103
106
|
|
104
107
|
If you have cloned this gem's git repo, then the example can also be run by loading
|
105
108
|
the table from a CSV file:
|
@@ -164,8 +167,8 @@ For example:
|
|
164
167
|
```
|
165
168
|
|
166
169
|
#### Column header symbols
|
167
|
-
All input and output column names are symbolized, and
|
168
|
-
expressions that refer to values in the input hash.
|
170
|
+
All input and output column names are symbolized, and those symbols may be used to form
|
171
|
+
simple expressions that refer to values in the input hash.
|
169
172
|
|
170
173
|
For example:
|
171
174
|
```ruby
|
@@ -195,8 +198,8 @@ may be simplified to:
|
|
195
198
|
These comparison operators are also supported: `!=`, `>`, `>=`, `<`, `<=`.
|
196
199
|
For more simple examples see `spec/csv_decision/examples_spec.rb`.
|
197
200
|
|
198
|
-
####
|
199
|
-
Sometimes it's more convenient to write guard
|
201
|
+
#### Input guard conditions
|
202
|
+
Sometimes it's more convenient to write guard expressions in a single column specialized for that purpose.
|
200
203
|
For example:
|
201
204
|
|
202
205
|
```ruby
|
@@ -215,8 +218,31 @@ table.decide(country: 'US', CUSIP: '123456789') #=> { ID: '123456789', ID_type:
|
|
215
218
|
table.decide(country: 'EU', CUSIP: '123456789', ISIN:'123456789012')
|
216
219
|
#=> { ID: '123456789012', ID_type: 'ISIN', len: 12 }
|
217
220
|
```
|
218
|
-
|
219
|
-
0-arity Ruby methods, the following comparison operators are
|
221
|
+
Input `guard:` columns may be anonymous, and must contain non-constant expressions. In addition to
|
222
|
+
0-arity Ruby methods, the following comparison operators are allowed: `==`, `!=`,
|
223
|
+
`>`, `>=`, `<` and `<=`. Also, regular expressions are supported - i.e., `=~` and `!~`.
|
224
|
+
|
225
|
+
#### Output if conditions
|
226
|
+
In some situations it is useful to apply filter conditions *after* all the output
|
227
|
+
columns have been derived. For example:
|
228
|
+
|
229
|
+
```ruby
|
230
|
+
data = <<~DATA
|
231
|
+
in :country, guard:, out :ID, out :ID_type, out :len, if:
|
232
|
+
US, :CUSIP.present?, :CUSIP, CUSIP8, :ID.length, :len == 8
|
233
|
+
US, :CUSIP.present?, :CUSIP, CUSIP9, :ID.length, :len == 9
|
234
|
+
US, :CUSIP.present?, :CUSIP, DUMMY, :ID.length,
|
235
|
+
, :ISIN.present?, :ISIN, ISIN, :ID.length, :len == 12
|
236
|
+
, :ISIN.present?, :ISIN, DUMMY, :ID.length,
|
237
|
+
, :CUSIP.present?, :CUSIP, DUMMY, :ID.length,
|
238
|
+
DATA
|
239
|
+
|
240
|
+
table = CSVDecision.parse(data)
|
241
|
+
table.decide(country: 'US', CUSIP: '123456789') #=> {ID: '123456789', ID_type: 'CUSIP9', len: 9}
|
242
|
+
table.decide(CUSIP: '12345678', ISIN:'1234567890') #=> {ID: '1234567890', ID_type: 'DUMMY', len: 10}
|
243
|
+
```
|
244
|
+
Output `if:` columns may be anonymous, and must contain non-constant expressions. In addition to
|
245
|
+
0-arity Ruby methods, the following comparison operators are allowed: `==`, `!=`,
|
220
246
|
`>`, `>=`, `<` and `<=`. Also, regular expressions are supported - i.e., `=~` and `!~`.
|
221
247
|
|
222
248
|
### Testing
|
@@ -233,18 +259,26 @@ Guard columns may be anonymous, and must contain non-constant expressions. In ad
|
|
233
259
|
`csv_decision` is still a work in progress, and will be enhanced to support
|
234
260
|
the following features:
|
235
261
|
* Text-only input columns may be indexed for faster lookup performance.
|
262
|
+
* Input hash values may be (conditionally) defaulted with a constant or a function call.
|
263
|
+
* Output columns may construct interpolated strings referencing column symbols.
|
236
264
|
* Supply a pre-defined library of functions that can be called within input columns to
|
237
265
|
implement matching logic or from the output columns to formulate the final decision.
|
238
266
|
* Available functions may be extended with a user-supplied library of Ruby methods
|
239
267
|
for tailored logic.
|
240
|
-
* Input hash values may be (conditionally) defaulted with a constant or a function call.
|
241
|
-
* Output columns may construct interpolated strings referencing column symbols.
|
242
|
-
* Can use post-match guard conditions to filter the results of multi-row
|
243
|
-
decision output.
|
244
268
|
|
245
269
|
### Reasons for the limitations of column expressions
|
246
270
|
The simple column expressions allowed by `csv_decision` are purposely limited for reasons of
|
247
271
|
understandability and maintainability. The whole point of this gem is to make decision rules
|
248
272
|
easier to express and comprehend as declarative, tabular logic.
|
249
273
|
While Ruby makes it easy to execute arbitrary code embedded within a CSV file,
|
250
|
-
this could easily result in hard to debug logic that also poses safety risks.
|
274
|
+
this could easily result in hard to debug logic that also poses safety risks.
|
275
|
+
|
276
|
+
## Changelog
|
277
|
+
|
278
|
+
See [CHANGELOG.md](./CHANGELOG.md) for a list of changes.
|
279
|
+
|
280
|
+
## License
|
281
|
+
|
282
|
+
CSV Decision © 2017-2018 by [Brett Vickers](mailto:brett@phillips-vickers.com).
|
283
|
+
CSV Decision is licensed under the MIT license. Please see the [LICENSE](./LICENSE)
|
284
|
+
document for more information.
|
data/csv_decision.gemspec
CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'csv_decision'
|
8
|
-
spec.version = '0.0.
|
8
|
+
spec.version = '0.0.9'
|
9
9
|
spec.authors = ['Brett Vickers']
|
10
10
|
spec.email = ['brett@phillips-vickers.com']
|
11
11
|
spec.description = 'CSV based Ruby decision tables.'
|
@@ -133,9 +133,9 @@
|
|
133
133
|
</div>
|
134
134
|
|
135
135
|
<div id="footer">
|
136
|
-
Generated on
|
136
|
+
Generated on Fri Jan 5 21:44:00 2018 by
|
137
137
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
138
|
-
0.9.12 (ruby-2.
|
138
|
+
0.9.12 (ruby-2.4.0).
|
139
139
|
</div>
|
140
140
|
|
141
141
|
</div>
|
@@ -123,6 +123,33 @@ interspersed and need not have unique names.</p>
|
|
123
123
|
<h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
|
124
124
|
<ul class="summary">
|
125
125
|
|
126
|
+
<li class="public ">
|
127
|
+
<span class="summary_signature">
|
128
|
+
|
129
|
+
<a href="#ifs-instance_method" title="#ifs (instance method)">#<strong>ifs</strong> ⇒ Hash{Integer=>Entry} </a>
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
</span>
|
134
|
+
|
135
|
+
|
136
|
+
|
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>if: columns.</p>
|
148
|
+
</div></span>
|
149
|
+
|
150
|
+
</li>
|
151
|
+
|
152
|
+
|
126
153
|
<li class="public ">
|
127
154
|
<span class="summary_signature">
|
128
155
|
|
@@ -254,19 +281,21 @@ interspersed and need not have unique names.</p>
|
|
254
281
|
<pre class="lines">
|
255
282
|
|
256
283
|
|
284
|
+
36
|
285
|
+
37
|
286
|
+
38
|
257
287
|
39
|
258
288
|
40
|
259
289
|
41
|
260
|
-
42
|
261
|
-
43
|
262
|
-
44</pre>
|
290
|
+
42</pre>
|
263
291
|
</td>
|
264
292
|
<td>
|
265
|
-
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line
|
293
|
+
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line 36</span>
|
266
294
|
|
267
295
|
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span>
|
268
296
|
<span class='ivar'>@ins</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
269
297
|
<span class='ivar'>@outs</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
298
|
+
<span class='ivar'>@ifs</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
270
299
|
<span class='comment'># TODO: @path = {}
|
271
300
|
</span> <span class='comment'># TODO: @defaults = {}
|
272
301
|
</span><span class='kw'>end</span></pre>
|
@@ -281,11 +310,76 @@ interspersed and need not have unique names.</p>
|
|
281
310
|
<h2>Instance Attribute Details</h2>
|
282
311
|
|
283
312
|
|
284
|
-
<span id="
|
313
|
+
<span id="ifs=-instance_method"></span>
|
285
314
|
<div class="method_details first">
|
286
|
-
<h3 class="signature first" id="
|
315
|
+
<h3 class="signature first" id="ifs-instance_method">
|
316
|
+
|
317
|
+
#<strong>ifs</strong> ⇒ <tt>Hash{Integer=>Entry}</tt>
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
</h3><div class="docstring">
|
324
|
+
<div class="discussion">
|
325
|
+
<p class="note private">
|
326
|
+
<strong>This method is part of a private API.</strong>
|
327
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
328
|
+
</p>
|
329
|
+
|
330
|
+
<p>if: columns.</p>
|
331
|
+
|
332
|
+
|
333
|
+
</div>
|
334
|
+
</div>
|
335
|
+
<div class="tags">
|
287
336
|
|
288
|
-
|
337
|
+
<p class="tag_title">Returns:</p>
|
338
|
+
<ul class="return">
|
339
|
+
|
340
|
+
<li>
|
341
|
+
|
342
|
+
|
343
|
+
<span class='type'>(<tt>Hash{Integer=>Entry}</tt>)</span>
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
—
|
348
|
+
<div class='inline'>
|
349
|
+
<p>All if: column dictionary entries.</p>
|
350
|
+
</div>
|
351
|
+
|
352
|
+
</li>
|
353
|
+
|
354
|
+
</ul>
|
355
|
+
|
356
|
+
</div><table class="source_code">
|
357
|
+
<tr>
|
358
|
+
<td>
|
359
|
+
<pre class="lines">
|
360
|
+
|
361
|
+
|
362
|
+
28
|
363
|
+
29
|
364
|
+
30</pre>
|
365
|
+
</td>
|
366
|
+
<td>
|
367
|
+
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line 28</span>
|
368
|
+
|
369
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_ifs'>ifs</span>
|
370
|
+
<span class='ivar'>@ifs</span>
|
371
|
+
<span class='kw'>end</span></pre>
|
372
|
+
</td>
|
373
|
+
</tr>
|
374
|
+
</table>
|
375
|
+
</div>
|
376
|
+
|
377
|
+
|
378
|
+
<span id="ins=-instance_method"></span>
|
379
|
+
<div class="method_details ">
|
380
|
+
<h3 class="signature " id="ins-instance_method">
|
381
|
+
|
382
|
+
#<strong>ins</strong> ⇒ <tt>Hash{Integer=>Entry}</tt>
|
289
383
|
|
290
384
|
|
291
385
|
|
@@ -311,7 +405,7 @@ interspersed and need not have unique names.</p>
|
|
311
405
|
<li>
|
312
406
|
|
313
407
|
|
314
|
-
<span class='type'>(<tt>Hash{Integer=>
|
408
|
+
<span class='type'>(<tt>Hash{Integer=>Entry}</tt>)</span>
|
315
409
|
|
316
410
|
|
317
411
|
|
@@ -330,12 +424,12 @@ interspersed and need not have unique names.</p>
|
|
330
424
|
<pre class="lines">
|
331
425
|
|
332
426
|
|
333
|
-
|
334
|
-
|
335
|
-
|
427
|
+
20
|
428
|
+
21
|
429
|
+
22</pre>
|
336
430
|
</td>
|
337
431
|
<td>
|
338
|
-
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line
|
432
|
+
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line 20</span>
|
339
433
|
|
340
434
|
<span class='kw'>def</span> <span class='id identifier rubyid_ins'>ins</span>
|
341
435
|
<span class='ivar'>@ins</span>
|
@@ -350,7 +444,7 @@ interspersed and need not have unique names.</p>
|
|
350
444
|
<div class="method_details ">
|
351
445
|
<h3 class="signature " id="outs-instance_method">
|
352
446
|
|
353
|
-
#<strong>outs</strong> ⇒ <tt>Hash{Integer=>
|
447
|
+
#<strong>outs</strong> ⇒ <tt>Hash{Integer=>Entry}</tt>
|
354
448
|
|
355
449
|
|
356
450
|
|
@@ -376,7 +470,7 @@ interspersed and need not have unique names.</p>
|
|
376
470
|
<li>
|
377
471
|
|
378
472
|
|
379
|
-
<span class='type'>(<tt>Hash{Integer=>
|
473
|
+
<span class='type'>(<tt>Hash{Integer=>Entry}</tt>)</span>
|
380
474
|
|
381
475
|
|
382
476
|
|
@@ -395,12 +489,12 @@ interspersed and need not have unique names.</p>
|
|
395
489
|
<pre class="lines">
|
396
490
|
|
397
491
|
|
398
|
-
|
399
|
-
|
400
|
-
|
492
|
+
24
|
493
|
+
25
|
494
|
+
26</pre>
|
401
495
|
</td>
|
402
496
|
<td>
|
403
|
-
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line
|
497
|
+
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line 24</span>
|
404
498
|
|
405
499
|
<span class='kw'>def</span> <span class='id identifier rubyid_outs'>outs</span>
|
406
500
|
<span class='ivar'>@outs</span>
|
@@ -416,9 +510,9 @@ interspersed and need not have unique names.</p>
|
|
416
510
|
</div>
|
417
511
|
|
418
512
|
<div id="footer">
|
419
|
-
Generated on
|
513
|
+
Generated on Fri Jan 5 21:44:00 2018 by
|
420
514
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
421
|
-
0.9.12 (ruby-2.
|
515
|
+
0.9.12 (ruby-2.4.0).
|
422
516
|
</div>
|
423
517
|
|
424
518
|
</div>
|
@@ -498,9 +498,9 @@
|
|
498
498
|
</div>
|
499
499
|
|
500
500
|
<div id="footer">
|
501
|
-
Generated on
|
501
|
+
Generated on Mon Jan 1 15:30:59 2018 by
|
502
502
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
503
|
-
0.9.12 (ruby-2.
|
503
|
+
0.9.12 (ruby-2.4.0).
|
504
504
|
</div>
|
505
505
|
|
506
506
|
</div>
|
@@ -120,7 +120,7 @@
|
|
120
120
|
|
121
121
|
|
122
122
|
|
123
|
-
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Columns/Dictionary.html" title="CSVDecision::Columns::Dictionary (class)">Dictionary</a></span
|
123
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Columns/Dictionary.html" title="CSVDecision::Columns::Dictionary (class)">Dictionary</a></span>
|
124
124
|
|
125
125
|
|
126
126
|
</p>
|
@@ -176,6 +176,30 @@
|
|
176
176
|
<li class="public ">
|
177
177
|
<span class="summary_signature">
|
178
178
|
|
179
|
+
<a href="#ifs-instance_method" title="#ifs (instance method)">#<strong>ifs</strong> ⇒ Hash{Index=>Entry} </a>
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
</span>
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
<span class="private note title">private</span>
|
191
|
+
|
192
|
+
|
193
|
+
<span class="summary_desc"><div class='inline'>
|
194
|
+
<p>if: columns hash keyed by column index.</p>
|
195
|
+
</div></span>
|
196
|
+
|
197
|
+
</li>
|
198
|
+
|
199
|
+
|
200
|
+
<li class="public ">
|
201
|
+
<span class="summary_signature">
|
202
|
+
|
179
203
|
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(table) ⇒ Columns </a>
|
180
204
|
|
181
205
|
|
@@ -303,19 +327,19 @@
|
|
303
327
|
<pre class="lines">
|
304
328
|
|
305
329
|
|
306
|
-
74
|
307
|
-
75
|
308
|
-
76
|
309
|
-
77
|
310
330
|
78
|
311
331
|
79
|
312
332
|
80
|
313
333
|
81
|
314
334
|
82
|
315
|
-
83
|
335
|
+
83
|
336
|
+
84
|
337
|
+
85
|
338
|
+
86
|
339
|
+
87</pre>
|
316
340
|
</td>
|
317
341
|
<td>
|
318
|
-
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line
|
342
|
+
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line 78</span>
|
319
343
|
|
320
344
|
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_table'>table</span><span class='rparen'>)</span>
|
321
345
|
<span class='comment'># If a column does not have a valid header cell, then it's empty of data.
|
@@ -323,7 +347,7 @@
|
|
323
347
|
</span> <span class='id identifier rubyid_row'>row</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Header.html" title="CSVDecision::Header (module)">Header</a></span></span><span class='period'>.</span><span class='id identifier rubyid_strip_empty_columns'><span class='object_link'><a href="Header.html#strip_empty_columns-class_method" title="CSVDecision::Header.strip_empty_columns (method)">strip_empty_columns</a></span></span><span class='lparen'>(</span><span class='label'>rows:</span> <span class='id identifier rubyid_table'>table</span><span class='period'>.</span><span class='id identifier rubyid_rows'>rows</span><span class='rparen'>)</span>
|
324
348
|
|
325
349
|
<span class='comment'># Build a dictionary of all valid data columns from the header row.
|
326
|
-
</span> <span class='ivar'>@dictionary</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="
|
350
|
+
</span> <span class='ivar'>@dictionary</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../CSVDecision.html" title="CSVDecision (module)">CSVDecision</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Dictionary.html" title="CSVDecision::Dictionary (module)">Dictionary</a></span></span><span class='period'>.</span><span class='id identifier rubyid_build'><span class='object_link'><a href="Dictionary.html#build-class_method" title="CSVDecision::Dictionary.build (method)">build</a></span></span><span class='lparen'>(</span><span class='label'>header:</span> <span class='id identifier rubyid_row'>row</span><span class='comma'>,</span> <span class='label'>dictionary:</span> <span class='const'><span class='object_link'><a href="Columns/Dictionary.html" title="CSVDecision::Columns::Dictionary (class)">Dictionary</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Columns/Dictionary.html#initialize-instance_method" title="CSVDecision::Columns::Dictionary#initialize (method)">new</a></span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_row'>row</span>
|
327
351
|
|
328
352
|
<span class='id identifier rubyid_freeze'>freeze</span>
|
329
353
|
<span class='kw'>end</span></pre>
|
@@ -382,12 +406,12 @@
|
|
382
406
|
<pre class="lines">
|
383
407
|
|
384
408
|
|
385
|
-
|
386
|
-
|
387
|
-
|
409
|
+
47
|
410
|
+
48
|
411
|
+
49</pre>
|
388
412
|
</td>
|
389
413
|
<td>
|
390
|
-
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line
|
414
|
+
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line 47</span>
|
391
415
|
|
392
416
|
<span class='kw'>def</span> <span class='id identifier rubyid_dictionary'>dictionary</span>
|
393
417
|
<span class='ivar'>@dictionary</span>
|
@@ -405,9 +429,67 @@
|
|
405
429
|
|
406
430
|
|
407
431
|
<div class="method_details first">
|
408
|
-
<h3 class="signature first" id="
|
432
|
+
<h3 class="signature first" id="ifs-instance_method">
|
433
|
+
|
434
|
+
#<strong>ifs</strong> ⇒ <tt>Hash{Index=>Entry}</tt>
|
435
|
+
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
|
440
|
+
</h3><div class="docstring">
|
441
|
+
<div class="discussion">
|
442
|
+
<p class="note private">
|
443
|
+
<strong>This method is part of a private API.</strong>
|
444
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
445
|
+
</p>
|
446
|
+
|
447
|
+
<p>if: columns hash keyed by column index.</p>
|
448
|
+
|
449
|
+
|
450
|
+
</div>
|
451
|
+
</div>
|
452
|
+
<div class="tags">
|
453
|
+
|
454
|
+
<p class="tag_title">Returns:</p>
|
455
|
+
<ul class="return">
|
456
|
+
|
457
|
+
<li>
|
458
|
+
|
459
|
+
|
460
|
+
<span class='type'>(<tt>Hash{Index=>Entry}</tt>)</span>
|
461
|
+
|
462
|
+
|
463
|
+
|
464
|
+
</li>
|
465
|
+
|
466
|
+
</ul>
|
467
|
+
|
468
|
+
</div><table class="source_code">
|
469
|
+
<tr>
|
470
|
+
<td>
|
471
|
+
<pre class="lines">
|
472
|
+
|
473
|
+
|
474
|
+
63
|
475
|
+
64
|
476
|
+
65</pre>
|
477
|
+
</td>
|
478
|
+
<td>
|
479
|
+
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line 63</span>
|
480
|
+
|
481
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_ifs'>ifs</span>
|
482
|
+
<span class='ivar'>@dictionary</span><span class='period'>.</span><span class='id identifier rubyid_ifs'>ifs</span>
|
483
|
+
<span class='kw'>end</span></pre>
|
484
|
+
</td>
|
485
|
+
</tr>
|
486
|
+
</table>
|
487
|
+
</div>
|
488
|
+
|
489
|
+
<div class="method_details ">
|
490
|
+
<h3 class="signature " id="ins-instance_method">
|
409
491
|
|
410
|
-
#<strong>ins</strong> ⇒ <tt>Hash{Index=>
|
492
|
+
#<strong>ins</strong> ⇒ <tt>Hash{Index=>Entry}</tt>
|
411
493
|
|
412
494
|
|
413
495
|
|
@@ -433,7 +515,7 @@
|
|
433
515
|
<li>
|
434
516
|
|
435
517
|
|
436
|
-
<span class='type'>(<tt>Hash{Index=>
|
518
|
+
<span class='type'>(<tt>Hash{Index=>Entry}</tt>)</span>
|
437
519
|
|
438
520
|
|
439
521
|
|
@@ -447,12 +529,12 @@
|
|
447
529
|
<pre class="lines">
|
448
530
|
|
449
531
|
|
450
|
-
|
451
|
-
|
452
|
-
|
532
|
+
51
|
533
|
+
52
|
534
|
+
53</pre>
|
453
535
|
</td>
|
454
536
|
<td>
|
455
|
-
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line
|
537
|
+
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line 51</span>
|
456
538
|
|
457
539
|
<span class='kw'>def</span> <span class='id identifier rubyid_ins'>ins</span>
|
458
540
|
<span class='ivar'>@dictionary</span><span class='period'>.</span><span class='id identifier rubyid_ins'>ins</span>
|
@@ -465,7 +547,7 @@
|
|
465
547
|
<div class="method_details ">
|
466
548
|
<h3 class="signature " id="outs-instance_method">
|
467
549
|
|
468
|
-
#<strong>outs</strong> ⇒ <tt>Hash{Index=>
|
550
|
+
#<strong>outs</strong> ⇒ <tt>Hash{Index=>Entry}</tt>
|
469
551
|
|
470
552
|
|
471
553
|
|
@@ -491,7 +573,7 @@
|
|
491
573
|
<li>
|
492
574
|
|
493
575
|
|
494
|
-
<span class='type'>(<tt>Hash{Index=>
|
576
|
+
<span class='type'>(<tt>Hash{Index=>Entry}</tt>)</span>
|
495
577
|
|
496
578
|
|
497
579
|
|
@@ -505,12 +587,12 @@
|
|
505
587
|
<pre class="lines">
|
506
588
|
|
507
589
|
|
508
|
-
|
509
|
-
|
510
|
-
|
590
|
+
57
|
591
|
+
58
|
592
|
+
59</pre>
|
511
593
|
</td>
|
512
594
|
<td>
|
513
|
-
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line
|
595
|
+
<pre class="code"><span class="info file"># File 'lib/csv_decision/columns.rb', line 57</span>
|
514
596
|
|
515
597
|
<span class='kw'>def</span> <span class='id identifier rubyid_outs'>outs</span>
|
516
598
|
<span class='ivar'>@dictionary</span><span class='period'>.</span><span class='id identifier rubyid_outs'>outs</span>
|
@@ -525,9 +607,9 @@
|
|
525
607
|
</div>
|
526
608
|
|
527
609
|
<div id="footer">
|
528
|
-
Generated on
|
610
|
+
Generated on Fri Jan 5 21:44:00 2018 by
|
529
611
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
530
|
-
0.9.12 (ruby-2.
|
612
|
+
0.9.12 (ruby-2.4.0).
|
531
613
|
</div>
|
532
614
|
|
533
615
|
</div>
|