Class: Query::Node::Operator

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

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parsed) ⇒ Operator

Returns a new instance of Operator.



28
29
30
31
# File 'lib/query/node/operator.rb', line 28

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



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

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