Class: CSVDecision::Matchers::Guard Private

Inherits:
Matcher
  • Object
show all
Defined in:
lib/csv_decision/matchers/guard.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 column symbol guard expression - e.g., >:column.present? or :column == 100.0.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Matcher

#initialize, #ins?

Constructor Details

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

Class Method Details

.matches?(cell) ⇒ false, CSVDecision::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.

Determine if the input cell string is recognised by this Matcher.

Parameters:

  • cell (String)

    Data row cell.

Returns:

  • (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.



130
131
132
133
134
135
# File 'lib/csv_decision/matchers/guard.rb', line 130

def self.matches?(cell)
  proc = symbol_proc(cell)
  return proc if proc

  symbol_guard(cell)
end

.regexp_match(symbol, value, hash) ⇒ 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.



50
51
52
53
54
# File 'lib/csv_decision/matchers/guard.rb', line 50

def self.regexp_match(symbol, value, hash)
  return false unless value.is_a?(String)
  data = hash[symbol]
  data.is_a?(String) && Matchers.regexp(value).match?(data)
end

.symbol_function(symbol, method, hash) ⇒ 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.



46
47
48
# File 'lib/csv_decision/matchers/guard.rb', line 46

def self.symbol_function(symbol, method, hash)
  hash[symbol].respond_to?(method) && hash[symbol].send(method)
end

Instance Method Details

#matches?(cell) ⇒ false, CSVDecision::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 CSVDecision::Proc object indicating if this is a constant or some type of function.

Parameters:

  • cell (String)

    Data row cell.

Returns:

  • (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.



139
140
141
# File 'lib/csv_decision/matchers/guard.rb', line 139

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

#outs?Boolean

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.

Return true if this matcher applies to output cells, false otherwise.

Returns:

  • (Boolean)

    Return true if this matcher applies to output cells, false otherwise.



144
145
146
# File 'lib/csv_decision/matchers/guard.rb', line 144

def outs?
  true
end