Class: Bio::NeXML::Matrix

Inherits:
Object
  • Object
show all
Includes:
Mapper
Defined in:
lib/bio/db/nexml/matrix.rb

Direct Known Subclasses

CellMatrix, SeqMatrix

Constant Summary collapse

@@writer =
Bio::NeXML::Writer.new

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mapper

#properties

Constructor Details

#initialize(options = {}) ⇒ Matrix

Returns a new instance of Matrix.



547
548
549
550
551
# File 'lib/bio/db/nexml/matrix.rb', line 547

def initialize( options = {} )
  @id = self.object_id
  properties( options ) unless options.empty?
  block.arity < 1 ? instance_eval( &block ) : block.call( self ) if block_given?        
end

Instance Attribute Details

#idObject

Because matrix elements don’t have id attributes, we will use object_id in this case



545
546
547
# File 'lib/bio/db/nexml/matrix.rb', line 545

def id
  @id
end

Instance Method Details

#add_row(row) ⇒ Object



553
554
555
# File 'lib/bio/db/nexml/matrix.rb', line 553

def add_row( row )
  # dummy for rdoc
end

#to_xmlObject



618
619
620
621
622
623
624
# File 'lib/bio/db/nexml/matrix.rb', line 618

def to_xml
  node = @@writer.create_node( "matrix" )
  self.each_row do |row|
    node << row.to_xml
  end
  node
end