Opening new command window from a Ruby application

I have a .rbw application. I only want it to open a command
window/terminal under certain circumstances, such as if there are error
messages, or if it needs user input. Otherwise, I don’t want to display
the window.

How can I get my ruby script to open up a new command window and then
read from it or write to it?

Also, can I open multiple command windows and read/write to a specific
command window?