Class | Bio::Nexus::Util
In: | lib/bio/db/nexus.rb
Parent: | Object

# DESCRIPTION

Bio::Nexus::Util is a class containing static helper methods

### Methods

array_to_string larger_than_zero longer_than_zero to_nexus_helper

### Public Class methods

array_to_string( ary )

Returns string as array separated by " ".

Arguments:

- (required) ary: Array

Returns: | String

[Source]

          # File lib/bio/db/nexus.rb, line 1821
    1821:       def Util::array_to_string( ary )
    1822:         str = String.new
    1823:         ary.each do | e |
    1824:           str << e << " "
    1825:         end
    1826:         str.chomp!( " " )
    1827:         str
    1828:       end

larger_than_zero( i )

Returns true if Integer i is not nil and larger than 0.

Arguments:

- (required) i: Integer

Returns: | true or false

[Source]

          # File lib/bio/db/nexus.rb, line 1835
    1835:       def Util::larger_than_zero( i )
    1836:         return ( i != nil && i.to_i > 0 )
    1837:       end

longer_than_zero( str )

Returns true if String str is not nil and longer than 0.

Arguments:

- (required) str: String

Returns: | true or false

[Source]

          # File lib/bio/db/nexus.rb, line 1844
    1844:       def Util::longer_than_zero( str )
    1845:         return ( str != nil && str.length > 0 )
    1846:       end

to_nexus_helper( block, lines )

Helper method to produce nexus formatted data.

Arguments:

- (required) block: Nexus:GenericBlock or its subclasses
- (required) block: Array

Returns: | String

[Source]

          # File lib/bio/db/nexus.rb, line 1804
    1804:       def Util::to_nexus_helper( block, lines )
    1805:         str = String.new
    1806:         str << BEGIN_BLOCK << " " << block << END_OF_LINE
    1807:         lines.each do | line |
    1808:           if ( line != nil )
    1809:             str << INDENTENTION << line << END_OF_LINE
    1810:           end
    1811:         end # do
    1812:         str << END_BLOCK << END_OF_LINE
    1813:         str
    1814:       end

[Validate]