Class: Dapp::Dapp::Shellout::Streaming::Proxy::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/dapp/dapp/shellout/streaming.rb

Direct Known Subclasses

Error

Instance Method Summary collapse

Constructor Details

#initialize(*streams, with_time: false) ⇒ Base

Returns a new instance of Base.



21
22
23
24
# File 'lib/dapp/dapp/shellout/streaming.rb', line 21

def initialize(*streams, with_time: false)
  @streams = streams
  @with_time = with_time
end

Instance Method Details

#<<(str) ⇒ Object



26
27
28
# File 'lib/dapp/dapp/shellout/streaming.rb', line 26

def <<(str)
  @streams.each { |s| s << format_string(str) }
end

#format_string(str) ⇒ Object



30
31
32
# File 'lib/dapp/dapp/shellout/streaming.rb', line 30

def format_string(str)
  str.lines.map { |l| "#{Dapp.log_time if @with_time}#{l.chomp}\n" }.join
end