Class: AsciiMath::AST::Matrix

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, rows, rparen) ⇒ Matrix

Returns a new instance of Matrix.



407
408
409
410
411
412
# File 'lib/asciimath/ast.rb', line 407

def initialize(lparen, rows, rparen)
  super()
  @lparen = lparen
  @rparen = rparen
  rows.map { |row| MatrixRow.new(row) }.each { |row_seq| add(row_seq) }
end

Instance Attribute Details

#lparenObject (readonly)

Returns the value of attribute lparen.



404
405
406
# File 'lib/asciimath/ast.rb', line 404

def lparen
  @lparen
end

#rparenObject (readonly)

Returns the value of attribute rparen.



405
406
407
# File 'lib/asciimath/ast.rb', line 405

def rparen
  @rparen
end

Instance Method Details

#==(o) ⇒ Object



421
422
423
424
425
426
# File 'lib/asciimath/ast.rb', line 421

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

#to_sObject



414
415
416
417
418
419
# File 'lib/asciimath/ast.rb', line 414

def to_s
  s = ""
  s << (lparen.nil? ? '{:' : lparen.text)
  s << child_nodes.map { |node| node.to_s }.join(",")
  s << (rparen.nil? ? ':}' : rparen.text)
end