Module: CSVDecision::Constant

Defined in:
lib/csv_decision/constant.rb

Overview

Recognise constant expressions in table data cells.

Constant Summary collapse

EXPRESSION =

Cell constant expression specified by prefixing the value with one of the three equality symbols.

Matchers.regexp("(?<operator>#{Matchers::EQUALS})\\s*(?<value>\\S.*)")
NON_NUMERIC =

Non-numeric constants recognised by CSV Decision.

{
  nil: nil,
  true: true,
  false: false
}.freeze

Class Method Summary collapse

Class Method Details

.matches?(cell) ⇒ Boolean, ...

Parameters:

  • cell (String)

    Data row cell.

Returns:

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



24
25
26
27
28
29
30
31
# File 'lib/csv_decision/constant.rb', line 24

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

  proc = non_numeric?(match)
  return proc if proc

  numeric?(match)
end