mardi 9 août 2016

pasting input to command line with multiple carriage returns

I'm new to ruby and have written a program that takes several lines of data (actually a JSON) and converts it into a table in the command line. Everything works fine with the JSON data embedded in the program but I would like to have it prompt the user to paste the data into the command line. I know about

gets and chomp

but since a JSON is formatted with multiple lines/carriage returns, when I paste in the command line it takes each line as a separate entry. I feel like the answer is simple but I'm having a hard time finding info online. I just want it to take everything I paste all at once and ignore all carriage returns. Any suggestions?

Thanks

Aucun commentaire:

Enregistrer un commentaire