diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2009-09-29 20:48:42 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2009-09-29 20:48:42 -0700 |
commit | 5ae604004516bc5944c38eee539b022bd7cf4820 (patch) | |
tree | 465fd16b50eb7df403c97708c347efad7ae7cf52 /lib/psych.rb | |
parent | 8328623efd2889ffcd513454d914385d480cce57 (diff) | |
download | psych-5ae604004516bc5944c38eee539b022bd7cf4820.zip |
round trip nil class
Diffstat (limited to 'lib/psych.rb')
-rw-r--r-- | lib/psych.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/psych.rb b/lib/psych.rb index 3ebc1fa..2d0cf0c 100644 --- a/lib/psych.rb +++ b/lib/psych.rb @@ -26,9 +26,23 @@ module Psych parse(yaml).to_ruby end + ### + # Parse a YAML string. Returns the first object of a YAML parse tree def self.parse yaml + yaml_ast(yaml).children.first.children.first + end + + ### + # Parse a YAML string in +yaml+. Returns the AST for the YAML parse tree. + def self.yaml_ast yaml parser = Psych::Parser.new(TreeBuilder.new) parser.parse yaml - parser.handler.root.children.first.children.first + parser.handler.root + end + + ### + # Dump object +o+ to a YAML string + def self.dump o + o.to_yaml end end |