Module: Psych::Streaming

Included in:
JSON::Stream, Stream
Defined in:
lib/psych/streaming.rb

Instance Method Summary collapse

Instance Method Details

#initialize(io) ⇒ Streaming

Create a new streaming emitter. Emitter will print to io. See Psych::Stream for an example.

Returns:

  • (Streaming)

    a new instance of Streaming



6
7
8
# File 'lib/psych/streaming.rb', line 6

def initialize io
  super({}, self.class.const_get(:Emitter).new(io))
end

#start(encoding = Nodes::Stream::UTF8) ⇒ Object

Start streaming using encoding



12
13
14
15
16
# File 'lib/psych/streaming.rb', line 12

def start encoding = Nodes::Stream::UTF8
  super.tap { yield self if block_given?  }
ensure
  finish if block_given?
end