Module: BioTable::LineParser
- Defined in:
- lib/bio-table/parser.rb
Class Method Summary collapse
-
.parse(line, in_format, split_on) ⇒ Object
Converts a string into an array of string fields.
Class Method Details
.parse(line, in_format, split_on) ⇒ Object
Converts a string into an array of string fields
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/bio-table/parser.rb', line 8 def LineParser::parse(line, in_format, split_on) if in_format == :csv CSV.parse(line)[0] elsif in_format == :split line.strip.split(split_on).map { |field| fld = field.strip fld = nil if fld == "NA" fld } elsif in_format == :regex line.strip.split(/#{split_on}/).map { |field| fld = field.strip fld = nil if fld == "NA" fld } else line.strip.split("\t").map { |field| fld = field.strip fld = nil if fld == "NA" fld } end end |