Class: Logging::IO::Pipe

Inherits:
Raw
  • Object
show all
Defined in:
lib/logging/io.rb

Overview

Write to a named pipe.

Instance Attribute Summary collapse

Attributes inherited from Base

#label

Instance Method Summary collapse

Methods inherited from Raw

#write_multiple_messages, #write_single_message

Constructor Details

#initialize(label, path) ⇒ Pipe

Returns a new instance of Pipe.



83
84
85
# File 'lib/logging/io.rb', line 83

def initialize(label, path)
  @label, @path = label, path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



82
83
84
# File 'lib/logging/io.rb', line 82

def path
  @path
end

Instance Method Details

#pipeObject



87
88
89
90
# File 'lib/logging/io.rb', line 87

def pipe
  # The w+ means we don't block.
  @pipe ||= open(self.path, 'w+')
end

#write(message) ⇒ Object



92
93
94
95
# File 'lib/logging/io.rb', line 92

def write(message)
  self.pipe.puts(message)
  self.pipe.flush
end