mirror of
https://github.com/ruby/ruby.git
synced 2025-08-27 15:06:10 +02:00

module. * ext/psych/lib/psych/stream.rb: extracted streaming specific methods to a module. * ext/psych/lib/psych/json/stream.rb: JSON stream inherits from JSONTree and includes streaming methods. * ext/psych/lib/psych/visitors/json_tree.rb: JSON does not support object references, so remove object reference testing when building JSON trees. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30936 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
22 lines
483 B
Ruby
22 lines
483 B
Ruby
module Psych
|
|
module Streaming
|
|
###
|
|
# Create a new streaming emitter. Emitter will print to +io+. See
|
|
# Psych::Stream for an example.
|
|
def initialize io
|
|
super({}, self.class.const_get(:Emitter).new(io))
|
|
end
|
|
|
|
###
|
|
# Start streaming using +encoding+
|
|
def start encoding = Nodes::Stream::UTF8
|
|
super.tap { yield self if block_given? }
|
|
ensure
|
|
finish if block_given?
|
|
end
|
|
|
|
private
|
|
def register target, obj
|
|
end
|
|
end
|
|
end
|