How about fifteen? On linux, you can use the mkfifo command:
$ mkfifo /tmp/mypipe
Then you can re-open STDIN on this channel:
STDIN.reopen '/tmp/mypipe'
All that can be written to this channel:
$ echo "roflcopter" > /tmp/mypipe
allows you to read data by the ruby โโprocess.
(Update) Caution with Lock
Since fifos locks until it is read and written (for example, reading is blocked if there is no write, and vice versa), it is best to handle multiple threads. One thread must do the reading, passing data to the queue, and the other should handle this input. Here is an example of this situation:
require 'thread' input = Queue.new threads = []
source share