Sha256: db26e38b7e4c95cdd064950fb01cb4c935af1551d999b453c66d633c542cee10

Contents?: true

Size: 584 Bytes

Versions: 1

Compression:

Stored size: 584 Bytes

Contents

module Alf
  class Renderer
    #
    # Implements Alf::Renderer contract for outputing YAML files.
    #
    class YAML < ::Alf::Renderer

      def self.mime_type
        "text/yaml"
      end

      def each
        return to_enum unless block_given?
        require "yaml"
        yield("---\n")
        Engine::ToArray.new(input).each do |tuple|
          yield "-" << tuple.to_hash.to_yaml[4..-1].gsub(/^/, "  ")[1..-1]
        end
        yield("\n")
      end

      Alf::Renderer.register(:yaml, "in YAML",  self)
    end # class YAML
  end # class Renderer
end # module Alf

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alf-core-0.15.0 lib/alf/renderer/yaml.rb