Class: Sh::Log::Broadcaster
Instance Method Summary collapse
- #flush ⇒ Object
-
#initialize(type) ⇒ Broadcaster
constructor
A new instance of Broadcaster.
- #puts(str) ⇒ Object
- #write(str) ⇒ Object
Constructor Details
#initialize(type) ⇒ Broadcaster
Returns a new instance of Broadcaster.
4 5 6 |
# File 'lib/sh_log.rb', line 4 def initialize type @type = type end |
Instance Method Details
#flush ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/sh_log.rb', line 18 def flush case @type when :stderr Log.error "> #{@buffer}" when :stdout Log.info "> #{@buffer}" end @buffer = "" end |
#puts(str) ⇒ Object
14 15 16 |
# File 'lib/sh_log.rb', line 14 def puts str write "#{str}\n" end |
#write(str) ⇒ Object
8 9 10 11 12 |
# File 'lib/sh_log.rb', line 8 def write str @buffer ||= "" @buffer << str flush if @buffer.end_with? "\n" end |