Class: CSVDecision2::Matchers::Symbol Private

Inherits:
Matcher
  • Object
show all
Defined in:
lib/csv_decision2/matchers/symbol.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.

Match cell against a symbolic expression - e.g., :column, > :column. Can also call a Ruby method pn the column value - e.g, .blank? or !.blank?

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Matcher

#initialize, #ins?, #outs?

Constructor Details

This class inherits a constructor from CSVDecision2::Matchers::Matcher

Class Method Details

.matches?(cell) ⇒ false, CSVDecision2::Proc

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 false if this cell is not a match; otherwise returns the CSVDecision2::Proc object indicating if this is a constant or some type of function.

Parameters:

  • cell (String)

    Data row cell.

Returns:

  • (false, CSVDecision2::Proc)

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



132
133
134
135
136
137
138
139
140
# File 'lib/csv_decision2/matchers/symbol.rb', line 132

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

  comparator = match['comparator']
  type = match['type']
  return false if comparator.nil? && type.nil?

  comparator_type(comparator: comparator || '=', type: type, name: match['name'].to_sym)
end

Instance Method Details

#matches?(cell) ⇒ false, CSVDecision2::Proc

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 false if this cell is not a match; otherwise returns the CSVDecision2::Proc object indicating if this is a constant or some type of function.

Parameters:

  • cell (String)

    Data row cell.

Returns:

  • (false, CSVDecision2::Proc)

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



144
145
146
# File 'lib/csv_decision2/matchers/symbol.rb', line 144

def matches?(cell)
  Symbol.matches?(cell)
end