class Keisan::AST::UnaryOperator
Public Class Methods
arity()
click to toggle source
# File lib/keisan/ast/unary_operator.rb, line 16 def self.arity ARITIES[:"u#{symbol}"] end
associativity()
click to toggle source
# File lib/keisan/ast/unary_operator.rb, line 24 def self.associativity ASSOCIATIVITIES[:"u#{symbol}"] end
new(children = [])
click to toggle source
Calls superclass method
Keisan::AST::Operator::new
# File lib/keisan/ast/unary_operator.rb, line 4 def initialize(children = []) children = Array(children) super(children) if children.count != 1 raise Exceptions::ASTError.new("Unary operator takes has a single child") end end
priority()
click to toggle source
# File lib/keisan/ast/unary_operator.rb, line 20 def self.priority PRIORITIES[:"u#{symbol}"] end
Public Instance Methods
child()
click to toggle source
# File lib/keisan/ast/unary_operator.rb, line 12 def child children.first end
simplify(context = nil)
click to toggle source
# File lib/keisan/ast/unary_operator.rb, line 36 def simplify(context = nil) self end
to_s()
click to toggle source
# File lib/keisan/ast/unary_operator.rb, line 28 def to_s if child.is_a?(Operator) "#{symbol.to_s}(#{child.to_s})" else "#{symbol.to_s}#{child.to_s}" end end