Method: Psych.load_stream
- Defined in:
- lib/psych.rb
.load_stream(yaml, filename = nil) ⇒ Object
Load multiple documents given in yaml. Returns the parsed documents as a list. If a block is given, each document will be converted to Ruby and passed to the block during parsing
Example:
Psych.load_stream("--- foo\n...\n--- bar\n...") # => ['foo', 'bar']
list = []
Psych.load_stream("--- foo\n...\n--- bar\n...") do |ruby|
list << ruby
end
list # => ['foo', 'bar']
457 458 459 460 461 462 463 464 465 |
# File 'lib/psych.rb', line 457 def self.load_stream yaml, filename = nil if block_given? parse_stream(yaml, filename) do |node| yield node.to_ruby end else parse_stream(yaml, filename).children.map { |child| child.to_ruby } end end |