Class: AsciiMath::AST::Paren

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

Instance Attribute Summary collapse

Attributes inherited from Node

#parent

Instance Method Summary collapse

Methods inherited from InnerNode

#[], #each, #length

Constructor Details

#initialize(lparen, e, rparen) ⇒ Paren

Returns a new instance of Paren.



139
140
141
142
143
144
# File 'lib/asciimath/ast.rb', line 139

def initialize(lparen, e, rparen)
  super()
  @lparen = lparen
  @rparen = rparen
  add(e) if e
end

Instance Attribute Details

#lparenObject (readonly)

Returns the value of attribute lparen.



136
137
138
# File 'lib/asciimath/ast.rb', line 136

def lparen
  @lparen
end

#rparenObject (readonly)

Returns the value of attribute rparen.



137
138
139
# File 'lib/asciimath/ast.rb', line 137

def rparen
  @rparen
end

Instance Method Details

#==(o) ⇒ Object



154
155
156
# File 'lib/asciimath/ast.rb', line 154

def ==(o)
  o.class == self.class && o.lparen == lparen && o.expression == expression && o.rparen == rparen
end

#expressionObject



146
147
148
# File 'lib/asciimath/ast.rb', line 146

def expression
  child_nodes[0]
end

#to_sObject



150
151
152
# File 'lib/asciimath/ast.rb', line 150

def to_s
  "#{lparen.nil? ? '' : lparen.text}#{expression}#{rparen.nil? ? '' : rparen.text}"
end