Class: TPPlus::Nodes::UnaryExpressionNode
- Defined in:
- lib/tp_plus/nodes/unary_expression_node.rb
Instance Attribute Summary collapse
-
#op ⇒ Object
readonly
Returns the value of attribute op.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
Instance Method Summary collapse
- #boolean_result? ⇒ Boolean
- #contains_expression? ⇒ Boolean
- #eval(context, options = {}) ⇒ Object
- #grouped? ⇒ Boolean
-
#initialize(op, x) ⇒ UnaryExpressionNode
constructor
A new instance of UnaryExpressionNode.
- #requires_mixed_logic?(context) ⇒ Boolean
Methods inherited from BaseNode
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
#op ⇒ Object (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 |
#x ⇒ Object (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
22 23 24 |
# File 'lib/tp_plus/nodes/unary_expression_node.rb', line 22 def boolean_result? false end |
#contains_expression? ⇒ 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,={}) if [:opposite] = .dup .delete(:opposite) # VarNode.eval() with opposite will add a ! @x.eval(context, ) elsif [:disable_mixed_logic] [:disable_mixed_logic] = false "#{@x.eval(context, options)}=OFF" else "#{@op.eval(context, options)}#{@x.eval(context, options)}" end end |
#grouped? ⇒ Boolean
10 11 12 |
# File 'lib/tp_plus/nodes/unary_expression_node.rb', line 10 def grouped? false end |
#requires_mixed_logic?(context) ⇒ Boolean
14 15 16 |
# File 'lib/tp_plus/nodes/unary_expression_node.rb', line 14 def requires_mixed_logic?(context) true end |