class Bio::Nexus::GenericBlock

DESCRIPTION

Bio::Nexus::GenericBlock represents a generic nexus block. It is mainly intended to be extended into more specific classes, although it is used for blocks not represented by more specific block classes. It has a name and a array for the tokenized content of a nexus block.

USAGE

require 'bio/db/nexus'

# Create a new parser:
nexus = Bio::Nexus.new( nexus_data_as_string )

# Get blocks for which no class exists (private blocks)
as Nexus::GenericBlock:
private_blocks = nexus.get_blocks_by_name( "my_block" )
# Get first block names "my_block":
my_block_0 = private_blocks[ 0 ]
# Get first token in first block names "my_block":
first_token = my_block_0.get_tokens[ 0 ]
# Get name of block (would return "my_block" in this case):
name = my_block_0.get_name
# Return data of block as nexus formatted String:
name = my_block_0.to_nexus

Public Class Methods

new( name ) click to toggle source

Creates a new GenericBlock object named 'name'.


Arguments:

  • (required) name: String

    # File lib/bio/db/nexus.rb
775 def initialize( name )
776   @name = name.chomp(";") 
777   @tokens = Array.new
778 end

Public Instance Methods

add_token( token ) click to toggle source

Adds a token to this.


Arguments:

  • (required) token: String

    # File lib/bio/db/nexus.rb
818 def add_token( token )
819   @tokens.push( token )
820 end
get_name() click to toggle source

Gets the name of this block.


Returns

String

    # File lib/bio/db/nexus.rb
784 def get_name
785   @name
786 end
get_tokens() click to toggle source

Returns contents as Array of Strings.


Returns

Array

    # File lib/bio/db/nexus.rb
792 def get_tokens
793   @tokens
794 end
to_nexus() click to toggle source

Should return a String describing this block as nexus formatted data.


Returns

String

    # File lib/bio/db/nexus.rb
808 def to_nexus
809   str = "generic block \"" + get_name + "\" [do not know how to write in nexus format]"
810   str
811 end
to_s() click to toggle source

Same as to_nexus.


Returns

String

    # File lib/bio/db/nexus.rb
800 def to_s
801   to_nexus
802 end
Also aliased as: to_str
to_str()
Alias for: to_s