Class: Lines::StreamOutputter

Inherits:
Object
  • Object
show all
Defined in:
lib/lines.rb

Overview

Handles output to any kind of IO

Constant Summary collapse

NL =
"\n".freeze

Instance Method Summary collapse

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