Class | YAML::Stream
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

new( opts = {} )

[Source]

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

### Public Instance methods

[]( i )

[Source]

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

add( doc )

[Source]

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

edit( doc_num, doc )

[Source]

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

emit( io = nil )

[Source]

    # File yaml/stream.rb, line 27
                    def emit( io = nil )
                # opts = @options.dup
                            # opts[:UseHeader] = true if @documents.length > 1
                out = YAML.emitter
                out.reset( io || io2 = StringIO.new )
                @documents.each { |v|
                    v.to_yaml( out )
                }
                io || ( io2.rewind; io2.read )
                    end

[Validate]