Module: CSVDecision::Symbol

Defined in:
lib/csv_decision/symbol.rb

Overview

Recognise column symbol comparison expressions in input column data cells - e.g., > :column or != :column.

Class Method Summary collapse

Class Method Details

.matches?(cell) ⇒ Boolean, ...

Parameters:

  • cell (String)

    Data row cell.

Returns:

  • (Boolean)
  • (false, CSVDecision::Proc)

    Returns false if this cell is not a match; otherwise returns the CSVDecision::Proc object indicating if this is a constant or some type of function.



64
65
66
67
68
69
70
71
72
# File 'lib/csv_decision/symbol.rb', line 64

def self.matches?(cell)
  match = SYMBOL_COMPARE_RE.match(cell)
  return false unless match

  comparator = match['comparator'] || '='
  name = match['name'].to_sym

  comparison(comparator: comparator, name: name)
end