source: extensions/gsdl-video/trunk/installed/cmdline/lib/ruby/1.8/yaml/stream.rb@ 18425

Last change on this file since 18425 was 18425, checked in by davidb, 15 years ago

Video extension to Greenstone

File size: 700 bytes
Line 
1module YAML
2
3 #
4 # YAML::Stream -- for emitting many documents
5 #
6 class Stream
7
8 attr_accessor :documents, :options
9
10 def initialize( opts = {} )
11 @options = opts
12 @documents = []
13 end
14
15 def []( i )
16 @documents[ i ]
17 end
18
19 def add( doc )
20 @documents << doc
21 end
22
23 def edit( doc_num, doc )
24 @documents[ doc_num ] = doc
25 end
26
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
37
38 end
39
40end
Note: See TracBrowser for help on using the repository browser.