Sha256: 8bd1efb8e117916c7b4eb9c5f5955b63d4801d0d869555b8a0ad437ad4d56a8c

Contents?: true

Size: 493 Bytes

Versions: 3

Compression:

Stored size: 493 Bytes

Contents

require 'yaml'
module DocParser
  # The YAMLOutput class generates a YAML file containing all rows as seperate
  # YAML documents
  # @see Output
  class YAMLOutput < Output
    # @!visibility private
    def write_row(row)
      fail MissingHeaderException if @header.nil? || @header.length == 0
      @doc ||= {}

      0.upto(@header.length - 1) do |counter|
        @doc[@header[counter]] = row.length > counter ? row[counter] : ''
      end

      YAML.dump @doc, @file
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
docparser-0.2.3 lib/docparser/output/yaml_output.rb
docparser-0.2.2 lib/docparser/output/yaml_output.rb
docparser-0.2.0 lib/docparser/output/yaml_output.rb