Sha256: b33eafc16ae1afabeb5bbb71f59c163301b8a96f11b178e913af1d5e442afe29

Contents?: true

Size: 681 Bytes

Versions: 1

Compression:

Stored size: 681 Bytes

Contents

class Object

  # Dumps the Object as YAML, and writes the YAML to the specified file.
  # Returns the Object unmodified.
  #
  # For information about available options see
  # {https://ruby-doc.org/stdlib/libdoc/psych/rdoc/Psych.html#method-c-dump
  # +YAML.dump+}.
  #
  # @example
  #   { "key" => "value" }.write_to_yaml("out.yaml")  # == { "key" => "value" }
  #   File.read("out.yaml")                           # == "---\nkey: value\n"
  #
  # @param file [String, Pathname]
  # @param options [Hash]
  # @return [self]
  def write_to_yaml(file, options = {})
    file.to_pathname.make_dirname.open("w") do |f|
      YAML.dump(self, f, options)
    end
    self
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pleasant_path-1.2.0 lib/pleasant_path/yaml/object.rb