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.



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

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.



402
403
404
# File 'lib/asciimath/ast.rb', line 402

def lparen
  @lparen
end

#rparenObject (readonly)

Returns the value of attribute rparen.



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

def rparen
  @rparen
end

Instance Method Details

#==(o) ⇒ Object



419
420
421
422
423
424
# File 'lib/asciimath/ast.rb', line 419

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

#to_sObject



412
413
414
415
416
417
# File 'lib/asciimath/ast.rb', line 412

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