lib/docparser/output/yaml_output.rb in docparser-0.2.3 vs lib/docparser/output/yaml_output.rb in docparser-0.3.0

- old
+ new

@@ -1,13 +1,16 @@ +# 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) - fail MissingHeaderException if @header.nil? || @header.length == 0 + raise MissingHeaderException if @header.nil? || @header.empty? + @doc ||= {} 0.upto(@header.length - 1) do |counter| @doc[@header[counter]] = row.length > counter ? row[counter] : '' end