Sha256: 76aecae6037dcd885d524d5df0e68ad3720a13e085b1129d2c4e80bd8e026d61

Contents?: true

Size: 560 Bytes

Versions: 5

Compression:

Stored size: 560 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)
      raise MissingHeaderException if @header.nil? || @header.length == 0
      @doc ||= {}
      0.upto(@header.length - 1) do |counter|
        if row.length > counter
          @doc[@header[counter]] = row[counter]
        else
          @doc[@header[counter]] = ''
        end
      end
      YAML.dump @doc, @file
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
docparser-0.1.4 lib/docparser/output/yaml_output.rb
docparser-0.1.3 lib/docparser/output/yaml_output.rb
docparser-0.1.2 lib/docparser/output/yaml_output.rb
docparser-0.1.1 lib/docparser/output/yaml_output.rb
docparser-0.1.0 lib/docparser/output/yaml_output.rb