Class: AsciiMath::AST::UnaryOp

Inherits:
InnerNode show all
Defined in:
lib/asciimath/ast.rb

Instance Attribute Summary

Attributes inherited from Node

#parent

Instance Method Summary collapse

Methods inherited from InnerNode

#[], #each, #length

Constructor Details

#initialize(operator, e) ⇒ UnaryOp

Returns a new instance of UnaryOp.



225
226
227
228
229
# File 'lib/asciimath/ast.rb', line 225

def initialize(operator, e)
  super()
  add(operator)
  add(e)
end

Instance Method Details

#==(o) ⇒ Object



243
244
245
# File 'lib/asciimath/ast.rb', line 243

def ==(o)
  o.class == self.class && o.operator == operator && o.operand == operand
end

#operandObject



235
236
237
# File 'lib/asciimath/ast.rb', line 235

def operand
  child_nodes[1]
end

#operatorObject



231
232
233
# File 'lib/asciimath/ast.rb', line 231

def operator
  child_nodes[0]
end

#to_sObject



239
240
241
# File 'lib/asciimath/ast.rb', line 239

def to_s
  "#{operator} #{operand}"
end