YAML::YamlNode#transform Method
transform
Applies transfer methods to this YamlNode and its children.

aYamlYamlNode.transform()

Parameters
None
Return Values
A Ruby object.

Details

The YamlNode#transform method is used to turn a tree of YamlNodes into a native Ruby object, as you would expect from a loading method, such as YAML::load. This method is handy if you want to perform a YPath select to grab a group of nodes and turn them into a new document.

players = YAML::parse( <<EOY )
  player:
    - given: Sammy
      family: Sosa
    - given: Ken
      family: Griffey
    - given: Mark
      family: McGwire
EOY

given = players.select( "/player/*/given" )
p given.transform
# prints:
#   ["Sammy", "Ken", "Mark"]
Ex. 45: Transforming the results of a YPath selection