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

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + require 'json' module DocParser # The JSONOutput class generates a JSON file containing all rows as seperate # Array elements # @see Output @@ -9,10 +11,10 @@ @file << '[' @doc = {} end def write_row(row) - fail MissingHeaderException if @header.nil? || @header.length == 0 + raise MissingHeaderException if @header.nil? || @header.empty? @file << ',' unless @file.pos <= 1 0.upto(@header.length - 1) do |counter| @doc[@header[counter]] = row.length > counter ? row[counter] : ''