Class: Bio::NeXML::Otu

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

Overview

DESCRIPTION

Otu represents a taxon; an implementation of the Taxon type. An Otu must have an 'id' and may take an an optional 'label'.

taxon1 = Bio::NeXML::Otu.new( 'taxon1', :label => 'Label for taxon1' )
taxon1.id    #=> 'taxon1'
taxon1.label #=> 'Label for taxon1'
taxon1.otus  #=> otus object they belong to; see docs for Otus

Constant Summary

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

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from Mapper

#properties

Constructor Details

- (Otu) initialize(id, options = {}, &block)

Create a new otu.

otu = Bio::NeXML::Otu.id( 'o1' )
otu = Bio::NeXML::Otu.id( 'o1', :label => 'A label' )


32
33
34
35
36
# File 'lib/bio/db/nexml/taxa.rb', line 32

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

Instance Attribute Details

- (Object) id

A file level unique identifier.



16
17
18
# File 'lib/bio/db/nexml/taxa.rb', line 16

def id
  @id
end

- (Object) label

A human readable description.



19
20
21
# File 'lib/bio/db/nexml/taxa.rb', line 19

def label
  @label
end

Instance Method Details

- (Object) to_xml



38
39
40
# File 'lib/bio/db/nexml/taxa.rb', line 38

def to_xml
  @@writer.create_node( "otu", @@writer.attributes( self, :id, :label ) )
end