YAML::Stream (Class)

In: yaml/stream.rb
Parent: Object

YAML::Stream — for emitting many documents

Methods

[]   add   edit   emit   new  

Attributes

documents  [RW] 
options  [RW] 

Public Class methods

[Source]

# File yaml/stream.rb, line 10
                def initialize( opts = {} )
                        @options = opts
                        @documents = []
                end

Public Instance methods

[Source]

# File yaml/stream.rb, line 15
        def []( i )
            @documents[ i ]
        end

[Source]

# File yaml/stream.rb, line 19
                def add( doc )
                        @documents << doc
                end

[Source]

# File yaml/stream.rb, line 23
                def edit( doc_num, doc )
                        @documents[ doc_num ] = doc
                end

[Source]

# File yaml/stream.rb, line 27
                def emit
            opts = @options.dup
                        opts[:UseHeader] = true if @documents.length > 1
                        ct = 0
            out = YAML::Syck::Emitter.new( opts )
            @documents.each { |v|
                if ct > 0
                    out << "\n--- " 
                end
                v.to_yaml( :Emitter => out )
                ct += 1
            }
            out.end_object
                end

[Validate]