class CSVDecision::Matchers::Numeric

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

Constants

COMPARATORS

Coerce the input value to a numeric representation before invoking the comparison. If the coercion fails, it will produce a nil value which always fails to match.

COMPARISON

For example: +>= 100+ or +!= 0+.

Public Class Methods

matches?(cell) click to toggle source

(see Matcher#matches?)

# 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

Public Instance Methods

matches?(cell) click to toggle source

(see Matcher#matches?)

# File lib/csv_decision/matchers/numeric.rb, line 39
def matches?(cell)
  Numeric.matches?(cell)
end