summaryrefslogtreecommitdiff
path: root/ext/psych/lib/psych/streaming.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ext/psych/lib/psych/streaming.rb')
-rw-r--r--ext/psych/lib/psych/streaming.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/ext/psych/lib/psych/streaming.rb b/ext/psych/lib/psych/streaming.rb
new file mode 100644
index 0000000000..c6fa109d5a
--- /dev/null
+++ b/ext/psych/lib/psych/streaming.rb
@@ -0,0 +1,22 @@
+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