You can use Running external commands with Open3 - makandra dev
to call the command line in Ruby and plugins.
I use it here in my Discourse Frotz (Interactive Fiction) plugin: discourse-frotz/lib/frotzbot.rb at 6054d38af0ab8e516a93416026f8e646f5c5ea56 · merefield/discourse-frotz · GitHub to interact with the terminal.
But if you are going that far you might consider writing native Ruby all the way. It’s a very pleasant language.