Class: UnaryNode

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

Overview

Class for unary expressions.

Instance Method Summary collapse

Constructor Details

#initialize(op, operand) ⇒ UnaryNode

Returns a new instance of UnaryNode.



283
284
285
286
# File 'lib/nodes.rb', line 283

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

Instance Method Details

#evaluate(scope) ⇒ Object



287
288
289
# File 'lib/nodes.rb', line 287

def evaluate(scope)
  return eval("#{@op}#{@operand.evaluate(scope)}")
end