Class: NexusParser::Tokens::RowVec

Inherits:
Token
  • Object
show all
Defined in:
lib/nexus_parser/tokens.rb

Instance Attribute Summary

Attributes inherited from Token

#value

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ RowVec

Returns a new instance of RowVec.



113
114
115
116
117
118
# File 'lib/nexus_parser/tokens.rb', line 113

def initialize(str)
  # meh! Ruby is simpler to read than Perl?
  # handles both () and {} style multistates
  s = str.split(/\(|\)|\}|\{/).collect{|s| s=~ /[\,|\s]/ ? s.split(/[\,|\s]/) : s}.inject([]){|sum, x| x.class == Array ? sum << x.delete_if {|y| y == "" } : sum + x.strip.split(//)}
  @value = s
end