class Bio::NeXML::State
State
defines a possible observation with its ‘symbol’ attribute. A state may be ambiguous. An ambiguous state must define an ambiguity mapping which may be ‘polymorphic’, resolved in an ‘and’ context, or uncertain, resolved in a ‘or’ context.
state = Bio::NeXML::State.new( 'state1', :label => 'A label' ) state.id #=> 'state1' state.label #=> 'A label' state.ambiguous? #=> true state.ambiguity #=> :polymorphic
Attributes
ambiguity[RW]
Polymorphic or uncertain.
id[RW]
A file level unique identifier.
label[RW]
A human readable description of the state.
symbol[R]
Observation for this state.
Public Class Methods
new( id, symbol = nil, options = {}, &block )
click to toggle source
# File lib/bio/db/nexml/matrix.rb, line 40 def initialize( id, symbol = nil, options = {}, &block ) @id = id symbol.is_a?( Hash ) ? options = symbol : self.symbol = symbol properties( options ) unless options.empty? block.arity < 1 ? instance_eval( &block ) : block.call( self ) if block_given? end
polymorphic( id, symbol = nil, options = {}, &block )
click to toggle source
# File lib/bio/db/nexml/matrix.rb, line 106 def polymorphic( id, symbol = nil, options = {}, &block ) state = new( id, symbol, options, &block ) state.ambiguity = :polymorphic state end
uncertain( id, symbol = nil, options = {}, &block )
click to toggle source
# File lib/bio/db/nexml/matrix.rb, line 112 def uncertain( id, symbol = nil, options = {}, &block ) state = new( id, symbol, options, &block ) state.ambiguity = :uncertain state end
Public Instance Methods
add_member( member )
click to toggle source
Takes a Bio::NeXML::State
object and adds it to the ambiguity mapping of the state. Returns # self
.
# File lib/bio/db/nexml/matrix.rb, line 53 def add_member( member ); end
ambiguous?()
click to toggle source
# File lib/bio/db/nexml/matrix.rb, line 55 def ambiguous? !!ambiguity end
count()
click to toggle source
# File lib/bio/db/nexml/matrix.rb, line 71 def count number_of_members end
Also aliased as: length
each( &block )
click to toggle source
Iterate over each member in self
passing it to the block given. If no block is provided, it returns an Enumerator.
# File lib/bio/db/nexml/matrix.rb, line 78 def each( &block ) @members.each( &block ) end
include?( member )
click to toggle source
# File lib/bio/db/nexml/matrix.rb, line 67 def include?( member ) has_member?( member ) end
polymorphic?()
click to toggle source
# File lib/bio/db/nexml/matrix.rb, line 59 def polymorphic? ambiguity == :polymorphic end
symbol=( symbol )
click to toggle source
# File lib/bio/db/nexml/matrix.rb, line 47 def symbol=( symbol ) @symbol = symbol end
to_str()
click to toggle source
# File lib/bio/db/nexml/matrix.rb, line 82 def to_str symbol.to_s end
Also aliased as: to_s
to_xml()
click to toggle source
# File lib/bio/db/nexml/matrix.rb, line 87 def to_xml tagname = nil if ambiguity == :polymorphic tagname = "polymorphic_state_set" elsif ambiguity == :uncertain tagname = "uncertain_state_set" else tagname = "state" end node = @@writer.create_node( tagname, @@writer.attributes( self, :id, :label, :symbol ) ) if count > 0 self.each_member do |member| node << @@writer.create_node( "member", :state => member.id ) end end node end
uncertain?()
click to toggle source
# File lib/bio/db/nexml/matrix.rb, line 63 def uncertain? ambiguity == :uncertain end