Class: Fnf::Fifo
- Inherits:
-
Object
- Object
- Fnf::Fifo
- Defined in:
- lib/fnf/fifo.rb
Instance Method Summary collapse
-
#initialize(file) ⇒ Fifo
constructor
A new instance of Fifo.
- #read(n) ⇒ Object
- #readline ⇒ Object
- #to_io ⇒ Object
Constructor Details
#initialize(file) ⇒ Fifo
Returns a new instance of Fifo.
4 5 6 7 8 9 10 |
# File 'lib/fnf/fifo.rb', line 4 def initialize(file) if !File.exists?(file) File.mkfifo(file) File.chmod(0666, file) end @pipe = File.open(file, "r+") end |
Instance Method Details
#read(n) ⇒ Object
24 25 26 |
# File 'lib/fnf/fifo.rb', line 24 def read(n) @pipe.read(n) end |
#readline ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/fnf/fifo.rb', line 12 def readline str = "" while ($_ = self.read(1)) != "\n" str << $_ end str << "\n" end |
#to_io ⇒ Object
20 21 22 |
# File 'lib/fnf/fifo.rb', line 20 def to_io @pipe.to_io end |