Skip to content

Instantly share code, notes, and snippets.

@memetor
Created September 7, 2014 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save memetor/ce8e10f7c58f758d1da9 to your computer and use it in GitHub Desktop.
Save memetor/ce8e10f7c58f758d1da9 to your computer and use it in GitHub Desktop.
module TSV
extend self
def parse(str)
str.split("\n").map {|x| x.split("\t")}
end
end
class Object
def to_tsv
return to_s unless kind_of? Enumerable
if first.kind_of? Enumerable
map {|x| x.join("\t")}.join("\n")
else
map {|x| x.to_s}.join("\n")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment