module Psych
def self.dump o, io = nil, options = {}
# Dump an array to an IO with indentation set
Psych.dump(['a', ['b']], indentation: 3) # => "---\n- a\n- - b\n"
# Dump an array with indentation set
Psych.dump(['a', 'b'], StringIO.new) # => #
# Dump an array to an IO object
Psych.dump(['a', 'b']) # => "---\n- a\n- b\n"
# Dump an array, get back a YAML string
Example:
Default: false.
[:header] Write %YAML [version] at the beginning of document.
Default: false.
strictly formal).
[:canonical] Write "canonical" YAML form (very verbose, yet
Default: 0 (meaning "wrap at 81").
[:line_width] Max character to wrap line at.
Default: 2.
otherwise option is ignored.
Acceptable value should be in 0..9 range,
[:indentation] Number of space characters used to indent.
Currently supported options are:
be dumped to that IO object.
to control the output format. If an IO object is passed in, the YAML will
Dump Ruby object +o+ to a YAML string. Optional +options+ may be passed in
Psych.dump(o, io, options) -> io object passed in
Psych.dump(o, io) -> io object passed in
Psych.dump(o, options) -> string of yaml
Psych.dump(o) -> string of yaml
call-seq:
##
def self.dump o, io = nil, options = {} if Hash === io options = io io = nil end visitor = Psych::Visitors::YAMLTree.create options visitor << o visitor.tree.yaml io, options end