module Sycl
Public Class Methods
dump(object)
click to toggle source
Sycl::dump(object)
is the Sycl
counterpart to YAML::dump(object). It takes a Sycl::Hash
or a Sycl::Array
, and renders it as YAML. Sycl
YAML output is always sorted in canonical order, so you can parse and re-emit data in a reliable way.
# File lib/sycl.rb, line 82 def self.dump(object) if (object.is_a?(::Hash) && !object.is_a?(Sycl::Hash)) || (object.is_a?(::Array) && !object.is_a?(Sycl::Array)) sycl_version = from_object object sycl_version.to_yaml else object.to_yaml end end
load(yaml)
click to toggle source
Sycl::load(yaml)
is the Sycl
counterpart to YAML::load(yaml). It accepts YAML text, and returns a Sycl::Hash
or Sycl::Array
object representing the parsed YAML.
# File lib/sycl.rb, line 64 def self.load(yaml) from_object YAML::load(yaml) end
load_file(filename)
click to toggle source
Sycl::load(filename)
is the Sycl
counterpart to YAML::load_file(filename). It accepts a filename, and returns a Sycl::Hash
or Sycl::Array
object representing the parsed YAML from that file.
# File lib/sycl.rb, line 73 def self.load_file(filename) from_object YAML::load_file(filename) end
Private Class Methods
from_object(o)
click to toggle source
# File lib/sycl.rb, line 94 def self.from_object(o) if o.is_a?(::Hash) Sycl::Hash.from_hash(o) elsif o.is_a?(::Array) Sycl::Array.from_array(o) else o end end