Method: String#split_tsv

Defined in:
lib/webget_ruby_ramp/string.rb

#split_tsvArray<String>

This is useful to split a TSV (Tab Separated Values) string into an array of rows, and each row into an array of fields.

Examples:

"foo\tgoo\thoo\n"ioo\tjoo\tkoo\nloo\tmoo\tnoo".split_tsv
=> [["foo", "goo", "hoo"], ["ioo", "joo", "koo"], ["loo", "moo", "noo"]]

Returns:

  • (Array<String>)

    an array that is the string split at newlines, then tabs.



47
48
49
# File 'lib/webget_ruby_ramp/string.rb', line 47

def split_tsv
  split(/\n/).map{|line| line.split(/\t/)}
end