Class: TPPlus::Nodes::UnaryExpressionNode

Inherits:
BaseNode
  • Object
show all
Defined in:
lib/tp_plus/nodes/unary_expression_node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseNode

#can_be_inlined?

Constructor Details

#initialize(op, x) ⇒ UnaryExpressionNode

Returns a new instance of UnaryExpressionNode.



5
6
7
8
# File 'lib/tp_plus/nodes/unary_expression_node.rb', line 5

def initialize(op, x)
  @op = OperatorNode.new(op)
  @x = x
end

Instance Attribute Details

#opObject (readonly)

Returns the value of attribute op.



4
5
6
# File 'lib/tp_plus/nodes/unary_expression_node.rb', line 4

def op
  @op
end

#xObject (readonly)

Returns the value of attribute x.



4
5
6
# File 'lib/tp_plus/nodes/unary_expression_node.rb', line 4

def x
  @x
end

Instance Method Details

#boolean_result?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/tp_plus/nodes/unary_expression_node.rb', line 22

def boolean_result?
  false
end

#contains_expression?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/tp_plus/nodes/unary_expression_node.rb', line 18

def contains_expression?
  true
end

#eval(context, options = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/tp_plus/nodes/unary_expression_node.rb', line 26

def eval(context,options={})
  if options[:opposite]
    new_options = options.dup
    new_options.delete(:opposite) # VarNode.eval() with opposite will add a !
    @x.eval(context, new_options)
  elsif options[:disable_mixed_logic]
    options[:disable_mixed_logic] = false
    "#{@x.eval(context, options)}=OFF"
  else
    "#{@op.eval(context, options)}#{@x.eval(context, options)}"
  end
end

#grouped?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/tp_plus/nodes/unary_expression_node.rb', line 10

def grouped?
  false
end

#requires_mixed_logic?(context) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/tp_plus/nodes/unary_expression_node.rb', line 14

def requires_mixed_logic?(context)
  true
end