Sha256: 9fb0ada5ceadf1cc4ca2995f63f05632768f5cb939ded943b19ee2ef9954e743
Contents?: true
Size: 925 Bytes
Versions: 11
Compression:
Stored size: 925 Bytes
Contents
module IMW module Formats # Provides methods for reading and writing YAML data. module Yaml include Enumerable # Return the content of this resource. # # Will pass a block to the outermost YAML data structure's each # method. # # @return [Hash, Array, String, Fixnum] whatever the YAML contained def load &block require 'yaml' yaml = YAML.load(io) if block_given? yaml.each(&block) else yaml end end # Iterate over the elements in the YAML. def each &block load(&block) end # Emit the +data+ into this resource. It must be opened for # writing. # # @param [Hash, String, Array, Fixnum] data the Ruby object to emit def emit data, options={} require 'yaml' write(data.to_yaml) self end end end end
Version data entries
11 entries across 11 versions & 1 rubygems