How can I read multiple documents from a YAML file?

Viewed 3062

I want to make a YAML file that consists of only hashes. However, I cannot iterate over it. When I try to load the YAML file with:

YAML.load_file('yamlFile.yml') 

it returns only the first hash in the file. Here is an example file I would like to create:

---
:reach_hypo: true
:liquid: true
---
:reach_hypo: true
:liquid: false
---
:reach_hypo: true
:liquid: true 

If I load the above file, I get:

{reach_hypo: true, liquid: true}

The only workaround I have found is to add all the hashes into an array, then write it to the YAML file. Is there a better way, such as a YAML method, to iterate over the YAML file?

3 Answers
Related