Class: AsciiMath::AST::Group

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) ⇒ Group

Returns a new instance of Group.



163
164
165
166
167
168
# File 'lib/asciimath/ast.rb', line 163

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.



160
161
162
# File 'lib/asciimath/ast.rb', line 160

def lparen
  @lparen
end

#rparenObject (readonly)

Returns the value of attribute rparen.



161
162
163
# File 'lib/asciimath/ast.rb', line 161

def rparen
  @rparen
end

Instance Method Details

#==(o) ⇒ Object



178
179
180
# File 'lib/asciimath/ast.rb', line 178

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

#expressionObject



170
171
172
# File 'lib/asciimath/ast.rb', line 170

def expression
  child_nodes[0]
end

#to_sObject



174
175
176
# File 'lib/asciimath/ast.rb', line 174

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