Class: Lines::StreamOutputter
- Inherits:
-
Object
- Object
- Lines::StreamOutputter
- Defined in:
- lib/lines.rb
Overview
Handles output to any kind of IO
Constant Summary collapse
- NL =
"\n".freeze
Instance Method Summary collapse
-
#initialize(stream = $stderr) ⇒ StreamOutputter
constructor
stream must accept a #write(str) message.
- #output(dumper, obj) ⇒ Object
Constructor Details
#initialize(stream = $stderr) ⇒ StreamOutputter
stream must accept a #write(str) message
157 158 159 160 161 |
# File 'lib/lines.rb', line 157 def initialize(stream = $stderr) @stream = stream # Is this needed ? @stream.sync = true if @stream.respond_to?(:sync) end |
Instance Method Details
#output(dumper, obj) ⇒ Object
163 164 165 166 |
# File 'lib/lines.rb', line 163 def output(dumper, obj) str = dumper.dump(obj) + NL @stream.write str end |