1require 'psych/tree_builder'
2
3module Psych
4  module Handlers
5    class DocumentStream < Psych::TreeBuilder # :nodoc:
6      def initialize &block
7        super
8        @block = block
9      end
10
11      def start_document version, tag_directives, implicit
12        n = Nodes::Document.new version, tag_directives, implicit
13        push n
14      end
15
16      def end_document implicit_end = !streaming?
17        @last.implicit_end = implicit_end
18        @block.call pop
19      end
20    end
21  end
22end
23