Class: Rgviz::LogicalExpression

Inherits:
Object
  • Object
show all
Defined in:
lib/rgviz/nodes.rb

Constant Summary collapse

And =
Token::And
Or =
Token::Or

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(operator, operands) ⇒ LogicalExpression

Returns a new instance of LogicalExpression.



218
219
220
221
# File 'lib/rgviz/nodes.rb', line 218

def initialize(operator, operands)
  @operator = operator
  @operands = operands
end

Instance Attribute Details

#operandsObject

Returns the value of attribute operands.



216
217
218
# File 'lib/rgviz/nodes.rb', line 216

def operands
  @operands
end

#operatorObject

Returns the value of attribute operator.



215
216
217
# File 'lib/rgviz/nodes.rb', line 215

def operator
  @operator
end

Instance Method Details

#accept(visitor) ⇒ Object



223
224
225
226
227
228
# File 'lib/rgviz/nodes.rb', line 223

def accept(visitor)
  if visitor.visit_logical_expression(self)
    operands.each{|x| x.accept visitor}
  end
  visitor.end_visit_logical_expression self
end

#to_sObject



230
231
232
# File 'lib/rgviz/nodes.rb', line 230

def to_s
  operands.map(&:to_s).join(" #{operator} ")
end