Class: Scripted::Output::CommandLogger
- Inherits:
-
Object
- Object
- Scripted::Output::CommandLogger
- Defined in:
- lib/scripted/output/command_logger.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#read ⇒ Object
readonly
Returns the value of attribute read.
-
#reader ⇒ Object
readonly
Returns the value of attribute reader.
-
#write ⇒ Object
readonly
Returns the value of attribute write.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(logger, command) ⇒ CommandLogger
constructor
A new instance of CommandLogger.
- #sync ⇒ Object
- #to_io ⇒ Object
Constructor Details
#initialize(logger, command) ⇒ CommandLogger
Returns a new instance of CommandLogger.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/scripted/output/command_logger.rb', line 9 def initialize(logger, command) @logger, @command = logger, command @read, @write = IO.pipe @reader = Thread.new do read.each_char do |char| logger.send_to_formatters :each_char, char, command end end end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
5 6 7 |
# File 'lib/scripted/output/command_logger.rb', line 5 def command @command end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
5 6 7 |
# File 'lib/scripted/output/command_logger.rb', line 5 def logger @logger end |
#read ⇒ Object (readonly)
Returns the value of attribute read.
7 8 9 |
# File 'lib/scripted/output/command_logger.rb', line 7 def read @read end |
#reader ⇒ Object (readonly)
Returns the value of attribute reader.
7 8 9 |
# File 'lib/scripted/output/command_logger.rb', line 7 def reader @reader end |
#write ⇒ Object (readonly)
Returns the value of attribute write.
7 8 9 |
# File 'lib/scripted/output/command_logger.rb', line 7 def write @write end |
Instance Method Details
#close ⇒ Object
33 34 35 36 37 38 |
# File 'lib/scripted/output/command_logger.rb', line 33 def close sync reader.exit write.close read.close end |
#sync ⇒ Object
27 28 29 30 31 |
# File 'lib/scripted/output/command_logger.rb', line 27 def sync read.sync write.sync sleep 0.01 end |
#to_io ⇒ Object
23 24 25 |
# File 'lib/scripted/output/command_logger.rb', line 23 def to_io write end |