Created
September 7, 2014 11:39
-
-
Save memetor/ce8e10f7c58f758d1da9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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