Class: Keisan::AST::UnaryOperator

Inherits:
Parent show all
Defined in:
lib/keisan/ast/unary_operator.rb

Instance Attribute Summary

Attributes inherited from Parent

#children

Instance Method Summary collapse

Methods inherited from Node

#value

Constructor Details

#initialize(children = []) ⇒ UnaryOperator

Returns a new instance of UnaryOperator.



4
5
6
7
8
9
10
# File 'lib/keisan/ast/unary_operator.rb', line 4

def initialize(children = [])
  children = Array.wrap(children)
  super
  if children.count != 1
    raise Keisan::Exceptions::ASTError.new("Unary operator takes has a single child")
  end
end