Class: Dapp::Helper::Streaming::Proxy::Base

Inherits:
Object
  • Object
show all
Includes:
Log
Defined in:
lib/dapp/helper/streaming.rb

Overview

Base

Direct Known Subclasses

Error

Instance Method Summary collapse

Methods included from Log

included, #log, #log_format_string, #log_indent, #log_indent_next, #log_indent_prev, #log_info, #log_secondary, #log_step, #log_time, #log_with_indent, #with_log_indent

Constructor Details

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

Returns a new instance of Base.



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

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

Instance Method Details

#<<(str) ⇒ Object



31
32
33
# File 'lib/dapp/helper/streaming.rb', line 31

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

#format_string(str) ⇒ Object



35
36
37
# File 'lib/dapp/helper/streaming.rb', line 35

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