Class: CSVDecision::Matchers::Range Private

Inherits:
Matcher
  • Object
show all
Defined in:
lib/csv_decision/matchers/range.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 cells against Ruby-like range expressions or their negation - e.g., 0...10 or !a..z.

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) ⇒ 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.

Match a table data cell string against a Ruby-like range expression.

(see Matcher#matches?)

Returns:

  • (Boolean)


17
18
19
20
21
22
23
24
25
26
27
# File 'lib/csv_decision/matchers/range.rb', line 17

def self.matches?(cell)
  if (match = NUMERIC_RANGE.match(cell))
    return range_proc(match: match, coerce: :to_numeric)
  end

  if (match = ALNUM_RANGE.match(cell))
    return range_proc(match: match)
  end

  false
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.

Ruby-like range expressions or their negation - e.g., 0...10 or !a..z.

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.



90
91
92
# File 'lib/csv_decision/matchers/range.rb', line 90

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