Class: Bio::Nexus::Util
Overview
DESCRIPTION
Bio::Nexus::Util is a class containing static helper methods
Class Method Summary collapse
-
.array_to_string(ary) ⇒ Object
Returns string as array separated by “ ”.
-
.larger_than_zero(i) ⇒ Object
Returns true if Integer i is not nil and larger than 0.
-
.longer_than_zero(str) ⇒ Object
Returns true if String str is not nil and longer than 0.
-
.to_nexus_helper(block, lines) ⇒ Object
Helper method to produce nexus formatted data.
Class Method Details
.array_to_string(ary) ⇒ Object
Returns string as array separated by “ ”.
Arguments:
-
(required) ary: Array
- Returns
-
String
1821 1822 1823 1824 1825 1826 1827 1828 |
# File 'lib/bio/db/nexus.rb', line 1821 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
1835 1836 1837 |
# File 'lib/bio/db/nexus.rb', line 1835 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
1844 1845 1846 |
# File 'lib/bio/db/nexus.rb', line 1844 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
1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 |
# File 'lib/bio/db/nexus.rb', line 1804 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 |