Class: Bio::NeXML::Char

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

Overview

A char specifies which states apply to matrix columns.

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mapper

#properties

Constructor Details

#initialize(id, states = nil, options = {}) ⇒ Char

Returns a new instance of Char.



138
139
140
141
142
143
144
145
# File 'lib/bio/db/nexml/matrix.rb', line 138

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

Instance Attribute Details

#idObject

A file level unique identifier.



126
127
128
# File 'lib/bio/db/nexml/matrix.rb', line 126

def id
  @id
end

#labelObject

A human readable description.



129
130
131
# File 'lib/bio/db/nexml/matrix.rb', line 129

def label
  @label
end

Instance Method Details

#to_xmlObject



147
148
149
# File 'lib/bio/db/nexml/matrix.rb', line 147

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