Sha256: 6c14dc6d469acfe746b8f4d1fc03d66653479cb2e0cdb516017a3ebd8e146757
Contents?: true
Size: 762 Bytes
Versions: 2
Compression:
Stored size: 762 Bytes
Contents
require 'multi_json' module DocParser # The JSONOutput class generates a JSON file containing all rows as seperate # Array elements # @see Output class JSONOutput < Output # @!visibility private def open_file @file << '[' @first = true @doc = {} end def write_row(row) raise MissingHeaderException if @header.nil? || @header.length == 0 if @first @first = false else @file << ',' end 0.upto(@header.length - 1) do |counter| if row.length > counter @doc[@header[counter]] = row[counter] else @doc[@header[counter]] = '' end end @file << MultiJson.dump(@doc) end def footer @file << ']' end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
docparser-0.1.4 | lib/docparser/output/json_output.rb |
docparser-0.1.3 | lib/docparser/output/json_output.rb |