YAML::parse( (String or IO) io )
The YAML::parse method loads a single YAML document from a stream into a YamlNode. The YamlNode can be used to apply YPath expressions or validate against a schema structure.
tree = YAML::parse( File.open( "README" ) ) puts tree.type_id # prints: # map title = tree.select( "/title" ) puts title.value # prints: # YAML.rb obj_tree = tree.transform puts obj_tree['title'] # prints: # YAML.rb
With the YamlNode, you can access data before it's typed and transformed into Ruby native types. A tree of YamlNodes can later be turned into Ruby native types by using the YamlNode#transform method.