Sha256: 691fa45cb118be8d3ab522ac8b3be5f0ede7d996594d78292c425aedbb259469

Contents?: true

Size: 521 Bytes

Versions: 1

Compression:

Stored size: 521 Bytes

Contents

# frozen_string_literal: true

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)
      raise MissingHeaderException if @header.nil? || @header.empty?

      @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

1 entries across 1 versions & 1 rubygems

Version Path
docparser-0.3.0 lib/docparser/output/yaml_output.rb