Class: CSVDecision::Matchers::Numeric Private

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

Recognise numeric comparison expressions - e.g., > 100 or != 0.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Matcher

#initialize, #ins?, #outs?

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.



29
30
31
32
33
34
35
36
# File 'lib/csv_decision/matchers/numeric.rb', line 29

def self.matches?(cell)
  return false unless (match = COMPARISON.match(cell))
  return false unless (numeric_cell = Matchers.to_numeric(match['value']))

  comparator = match['comparator']
  Matchers::Proc.new(type: :proc,
                     function: COMPARATORS[comparator].curry[numeric_cell].freeze)
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.

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.



39
40
41
# File 'lib/csv_decision/matchers/numeric.rb', line 39

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