Class: CSVDecision::Decision Private
- Inherits:
-
Object
- Object
- CSVDecision::Decision
- Defined in:
- lib/csv_decision/decision.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Accumulate the matching row(s) and calculate the final result.
Instance Method Summary collapse
-
#initialize(table:, input:) ⇒ Decision
constructor
private
A new instance of Decision.
-
#scan(table:, input:) ⇒ {Symbol=>Object}
private
Scan the decision table up against the input hash.
Constructor Details
#initialize(table:, input:) ⇒ Decision
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Decision.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/csv_decision/decision.rb', line 13 def initialize(table:, input:) # The result object is a hash of values, and each value will be an array if this is # a multi-row result for the +first_match: false+ option. @result = Result.new(table: table, input: input) # All rows picked by the matching process. An array if +first_match: false+, otherwise # a single row. @rows_picked = [] # Relevant table attributes table_attributes(table) end |
Instance Method Details
#scan(table:, input:) ⇒ {Symbol=>Object}
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Scan the decision table up against the input hash.
30 31 32 33 34 35 36 37 |
# File 'lib/csv_decision/decision.rb', line 30 def scan(table:, input:) table.each do |row, index| # +row_scan+ returns false if more rows need to be scanned, truthy otherwise. return result if row_scan(input: input, row: row, scan_row: table.scan_rows[index]) end result end |