Class: Bio::NeXML::Sequence

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

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 = {}) ⇒ Sequence

Returns a new instance of Sequence.



510
511
512
513
514
# File 'lib/bio/db/nexml/matrix.rb', line 510

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

Instance Attribute Details

#idObject

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



508
509
510
# File 'lib/bio/db/nexml/matrix.rb', line 508

def id
  @id
end

#valueObject

Returns the value of attribute value.



504
505
506
# File 'lib/bio/db/nexml/matrix.rb', line 504

def value
  @value
end

Instance Method Details

#each_value(&block) ⇒ Object

:yields: value



521
522
523
524
525
526
527
# File 'lib/bio/db/nexml/matrix.rb', line 521

def each_value( &block ) # :yields: value
  if block_given?
    cells.each { |c| yield c.value }
  else
    enum_for( :each_value )
  end
end

#to_xmlObject



529
530
531
532
533
# File 'lib/bio/db/nexml/matrix.rb', line 529

def to_xml
  node = @@writer.create_node( "seq" )
  node << self.value
  node
end

#typeObject



516
517
518
519
# File 'lib/bio/db/nexml/matrix.rb', line 516

def type
  return nil if cells.empty?
  cells.first.bound? ? :granular : :raw
end