Module: Sycl
- Defined in:
- lib/sycl.rb
Defined Under Namespace
Class Method Summary collapse
-
.dump(object) ⇒ Object
Sycl::dump(object) is the Sycl counterpart to YAML::dump(object).
-
.load(yaml) ⇒ Object
Sycl::load(yaml) is the Sycl counterpart to YAML::load(yaml).
-
.load_file(filename) ⇒ Object
Sycl::load(filename) is the Sycl counterpart to YAML::load_file(filename).
Class Method Details
.dump(object) ⇒ Object
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.
82 83 84 85 86 87 88 89 90 |
# 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) ⇒ Object
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.
64 65 66 |
# File 'lib/sycl.rb', line 64 def self.load(yaml) from_object YAML::load(yaml) end |
.load_file(filename) ⇒ Object
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.
73 74 75 |
# File 'lib/sycl.rb', line 73 def self.load_file(filename) from_object YAML::load_file(filename) end |