Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

class method

Psych.load_stream

load_stream(yaml, filename: nil, fallback: [], **kwargs) { |to_ruby(**kwargs)| ... }

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:

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']
See also .load_file .parse .load .parse_file also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0