Class: Rgviz::UnaryExpression

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

Constant Summary collapse

Not =
Token::Not
IsNull =
:'is null'
IsNotNull =
:'is not null'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(operator, operand) ⇒ UnaryExpression

Returns a new instance of UnaryExpression.



281
282
283
284
# File 'lib/rgviz/nodes.rb', line 281

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

Instance Attribute Details

#operandObject

Returns the value of attribute operand.



278
279
280
# File 'lib/rgviz/nodes.rb', line 278

def operand
  @operand
end

#operatorObject

Returns the value of attribute operator.



279
280
281
# File 'lib/rgviz/nodes.rb', line 279

def operator
  @operator
end

Instance Method Details

#accept(visitor) ⇒ Object



286
287
288
289
290
291
# File 'lib/rgviz/nodes.rb', line 286

def accept(visitor)
  if visitor.visit_unary_expression(self)
    operand.accept visitor
  end
  visitor.end_visit_unary_expression self
end

#to_sObject



293
294
295
296
297
298
299
# File 'lib/rgviz/nodes.rb', line 293

def to_s
  if operator == Not
    "not #{operand}"
  else
    "#{operand} #{operator}"
  end
end