class TPPlus::Nodes::VarNode

Attributes

identifier[R]

Public Class Methods

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

Public Instance Methods

constant?() click to toggle source
# File lib/tp_plus/nodes/var_node.rb, line 13
def constant?
  @identifier.upcase == @identifier
end
eval(context,options={}) click to toggle source
# File lib/tp_plus/nodes/var_node.rb, line 27
def eval(context,options={})
  return target_node(context).eval(context) if constant?

  s = ""
  if options[:opposite]
    s += "!"
  end

  with_parens(s + target_node(context).eval(context, options), options)
end
requires_mixed_logic?(context) click to toggle source
# File lib/tp_plus/nodes/var_node.rb, line 17
def requires_mixed_logic?(context)
  target_node(context).requires_mixed_logic?(context)
end
target_node(context) click to toggle source
# File lib/tp_plus/nodes/var_node.rb, line 9
def target_node(context)
  constant? ? context.get_constant(@identifier) : context.get_var(@identifier)
end
with_parens(s, options) click to toggle source
# File lib/tp_plus/nodes/var_node.rb, line 21
def with_parens(s, options)
  return s unless options[:as_condition]

  "(#{s})"
end