Method: Fifo#gets
- Defined in:
- lib/ruby-fifo/fifo.rb
#gets ⇒ Object
Reads from the Fifo until it encounters a new line. Will block the current thread of execution until it hits a new line. This includes when the fifo is empty and nothing is writing to it.
Example:
w = Fifo.new('path/to/fifo', :w)
r = Fifo.new('path/to/fifo', :r)
w.puts "Hello, world!"
r.gets
#=> "Hello, world!\n"
126 127 128 129 130 |
# File 'lib/ruby-fifo/fifo.rb', line 126 def gets str = "" str << (r = self.read(1)) until r == "\n" str end |