Class: Bio::Nexus::Util

Inherits:
Object show all
Defined in:
lib/bio/db/nexus.rb

Overview

DESCRIPTION

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

Class Method Summary collapse

Class Method Details

.array_to_string(ary) ⇒ Object

Returns string as array separated by “ ”.


Arguments:

  • (required) ary: Array

Returns

String



1822
1823
1824
1825
1826
1827
1828
1829
# File 'lib/bio/db/nexus.rb', line 1822

def Util::array_to_string( ary )
  str = String.new
  ary.each do | e |
    str << e << " "
  end
  str.chomp!( " " )
  str  
end

.larger_than_zero(i) ⇒ Object

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


Arguments:

  • (required) i: Integer

Returns

true or false



1836
1837
1838
# File 'lib/bio/db/nexus.rb', line 1836

def Util::larger_than_zero( i )
  return ( i != nil && i.to_i > 0 )
end

.longer_than_zero(str) ⇒ Object

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


Arguments:

  • (required) str: String

Returns

true or false



1845
1846
1847
# File 'lib/bio/db/nexus.rb', line 1845

def Util::longer_than_zero( str )
  return ( str != nil && str.length > 0 )
end

.to_nexus_helper(block, lines) ⇒ Object

Helper method to produce nexus formatted data.


Arguments:

  • (required) block: Nexus:GenericBlock or its subclasses

  • (required) block: Array

Returns

String



1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
# File 'lib/bio/db/nexus.rb', line 1805

def Util::to_nexus_helper( block, lines )
  str = String.new
  str << BEGIN_BLOCK << " " << block << END_OF_LINE
  lines.each do | line |
    if ( line != nil )
      str << INDENTENTION << line << END_OF_LINE
    end
  end # do
  str << END_BLOCK << END_OF_LINE
  str
end