Class: Cadenza::BooleanInverseNode

Inherits:
Object
  • Object
show all
Includes:
TreeNode
Defined in:
lib/cadenza/nodes/boolean_inverse_node.rb

Overview

The BooleanInverseNode takes an expression and evaluates the logical inverse of that expression so any expression that evaluates to true will return false and vice versa.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from TreeNode

#to_tree

Constructor Details

#initialize(expression) ⇒ BooleanInverseNode

creates a new Cadenza::BooleanInverseNode with the given expression

Parameters:


13
14
15
# File 'lib/cadenza/nodes/boolean_inverse_node.rb', line 13

def initialize(expression)
   @expression = expression
end

Instance Attribute Details

#expressionOperationNode

Returns an evaluatable expression node.

Returns:


9
10
11
# File 'lib/cadenza/nodes/boolean_inverse_node.rb', line 9

def expression
  @expression
end

Instance Method Details

#==(rhs) ⇒ Boolean

Returns if the given Cadenza::BooleanInverseNode is equivalent by value.

Parameters:

Returns:


19
20
21
# File 'lib/cadenza/nodes/boolean_inverse_node.rb', line 19

def ==(rhs)
   @expression == rhs.expression
end

#eval(context) ⇒ Object

Returns the value of this node evaluated with the data in the given Context.

Parameters:

Returns:

  • the value of this node evaluated with the data in the given Context


25
26
27
28
# File 'lib/cadenza/nodes/boolean_inverse_node.rb', line 25

def eval(context)
   #TODO: rename me to .evaluate
   !@expression.eval(context)
end