Class: Psychic::Shell::IOToLog
- Inherits:
-
IO
- Object
- IO
- Psychic::Shell::IOToLog
- Defined in:
- lib/psychic/shell/mixlib_shellout_executor.rb
Instance Method Summary collapse
-
#initialize(logger) ⇒ IOToLog
constructor
A new instance of IOToLog.
- #write(string) ⇒ Object
Constructor Details
#initialize(logger) ⇒ IOToLog
Returns a new instance of IOToLog.
6 7 8 9 |
# File 'lib/psychic/shell/mixlib_shellout_executor.rb', line 6 def initialize(logger) @logger = logger @buffer = '' end |
Instance Method Details
#write(string) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/psychic/shell/mixlib_shellout_executor.rb', line 11 def write(string) (@buffer + string).lines.each do |line| if line.end_with? "\n" @buffer = '' @logger.info(line.rstrip) else @buffer = line end end end |