Class: Bio::NeXML::States

Inherits:
Object
  • Object
show all
Includes:
Mapper, Enumerable
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(id, options = {}) ⇒ States

Returns a new instance of States.



171
172
173
174
175
# File 'lib/bio/db/nexml/matrix.rb', line 171

def initialize( id, options = {} )
  @id = id
  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.



158
159
160
# File 'lib/bio/db/nexml/matrix.rb', line 158

def id
  @id
end

#labelObject

A human readable description of the state.



161
162
163
# File 'lib/bio/db/nexml/matrix.rb', line 161

def label
  @label
end

Instance Method Details

#add_state(state) ⇒ Object

dummy for rdoc



183
# File 'lib/bio/db/nexml/matrix.rb', line 183

def add_state( state ); end

#create_state(symbol = nil, options = {}) ⇒ Object



177
178
179
180
181
# File 'lib/bio/db/nexml/matrix.rb', line 177

def create_state( symbol = nil, options = {} )
  state = State.new( Bio::NeXML.generate_id( State ), symbol, options )
  add_state( state )
  state     
end

#delete_state(state) ⇒ Object

dummy for rdoc



185
# File 'lib/bio/db/nexml/matrix.rb', line 185

def delete_state( state ); end

#each(&block) ⇒ Object

Iterate over each state set in self passing it to the block given. If no block is provided, it returns an Enumerator.



206
207
208
# File 'lib/bio/db/nexml/matrix.rb', line 206

def each( &block )
  @states.each( &block )
end

#each_char(state) ⇒ Object

dummy for rdoc



193
# File 'lib/bio/db/nexml/matrix.rb', line 193

def each_char( state ); end

#each_state(state) ⇒ Object

dummy for rdoc



191
# File 'lib/bio/db/nexml/matrix.rb', line 191

def each_state( state ); end

#get_state_by_id(state) ⇒ Object

dummy for rdoc



189
# File 'lib/bio/db/nexml/matrix.rb', line 189

def get_state_by_id( state ); end

#get_state_by_symbol(symbol) ⇒ Object



199
200
201
202
# File 'lib/bio/db/nexml/matrix.rb', line 199

def get_state_by_symbol( symbol )
  matches = each_state.select{ |s| s.symbol == symbol }
  matches.first
end

#has_state?(state) ⇒ Boolean

dummy for rdoc

Returns:

  • (Boolean)


187
# File 'lib/bio/db/nexml/matrix.rb', line 187

def has_state?( state ); end

#include?(state) ⇒ Boolean

Returns:

  • (Boolean)


195
196
197
# File 'lib/bio/db/nexml/matrix.rb', line 195

def include?( state )
  has_state?( state )
end

#to_xmlObject



210
211
212
213
214
215
216
# File 'lib/bio/db/nexml/matrix.rb', line 210

def to_xml
  node = @@writer.create_node( "states", @@writer.attributes( self, :id, :label ) )
  self.each_state do |state|
    node << state.to_xml
  end
  node
end