Class: Query::Node::Operator

Inherits:
Query::Node show all
Defined in:
lib/query/node/operator.rb

Constant Summary collapse

PREFIXES =
{
  "+" => "",
  "-" => "!",
  "!" => "!",
  "" => "",
  nil => ""
}.freeze
SUFFIXES =
{
  "^" => "^",
  "$" => "$",
  ">=" => ">=",
  "=>" => ">=",
  "<=" => "<=",
  "=<" => "<=",
  "<" => "<",
  ">" => ">",
  "!" => "!",
  ":::" => ":",
  "::" => ":",
  ":" => ":",
  "=" => "=",
  "==" => "=",
  "===" => "="
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parsed) ⇒ Operator

Returns a new instance of Operator.



34
35
36
37
# File 'lib/query/node/operator.rb', line 34

def initialize(parsed)
  self.prefix = parsed.delete(:prefix)
  self.suffix = parsed.delete(:suffix)
end

Instance Attribute Details

#prefixObject

Returns the value of attribute prefix.



6
7
8
# File 'lib/query/node/operator.rb', line 6

def prefix
  @prefix
end

#suffixObject

Returns the value of attribute suffix.



6
7
8
# File 'lib/query/node/operator.rb', line 6

def suffix
  @suffix
end

Instance Method Details

#evaluate(**_args) ⇒ Object



39
40
41
# File 'lib/query/node/operator.rb', line 39

def evaluate(**_args)
  "#{PREFIXES.fetch(prefix)}#{SUFFIXES.fetch(suffix)}"
end