Class YAML::Stream
In: lib/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 lib/yaml/stream.rb, line 10
10:                 def initialize( opts = {} )
11:                         @options = opts
12:                         @documents = []
13:                 end

Public Instance methods

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Validate]