class TPPlus::Nodes::OperatorNode

Attributes

string[R]

Public Class Methods

new(string) click to toggle source
# File lib/tp_plus/nodes/operator_node.rb, line 5
def initialize(string)
  @string = string
end

Public Instance Methods

bang?() click to toggle source
# File lib/tp_plus/nodes/operator_node.rb, line 9
def bang?
  @string == "!"
end
boolean?() click to toggle source
# File lib/tp_plus/nodes/operator_node.rb, line 22
def boolean?
  case @string
  when "&&", "||", "!"#, "==", "<>", ">", ">=", "<", "<="
    true
  else
    false
  end
end
eval(context,options={}) click to toggle source
# File lib/tp_plus/nodes/operator_node.rb, line 31
def eval(context,options={})
  if options[:opposite]
    case @string
    when "=="
      "<>"
    when "!=", "<>"
      "="
    when ">"
      "<="
    when "<"
      ">="
    when ">="
      "<"
    when "<="
      ">"
    when "!"
      ""
    when "||"
      " AND "
    when "&&"
      " OR "
    when "DIV"
      " MOD "
    else
      "#{@string}"
    end
  else
    case @string
    when "=="
      "="
    when "!="
      "<>"
    when "&&"
      " AND "
    when "||"
      " OR "
    when "%"
      " MOD "
    when "DIV"
      " DIV "
    else
      "#{@string}"
    end
  end
end
requires_mixed_logic?(context) click to toggle source
# File lib/tp_plus/nodes/operator_node.rb, line 13
def requires_mixed_logic?(context)
  case @string
  when "&&", "||", "!"
    true
  else
    false
  end
end