Sha256: 8e672e0629dd39c2a6db87f12910bac67fbc1486472ac25e0d3c4123b4b026df
Contents?: true
Size: 629 Bytes
Versions: 3
Compression:
Stored size: 629 Bytes
Contents
require '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 << '[' @doc = {} end def write_row(row) fail MissingHeaderException if @header.nil? || @header.length == 0 @file << ',' unless @file.pos <= 1 0.upto(@header.length - 1) do |counter| @doc[@header[counter]] = row.length > counter ? row[counter] : '' end @file << JSON.generate(@doc) end def footer @file << ']' end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
docparser-0.2.3 | lib/docparser/output/json_output.rb |
docparser-0.2.2 | lib/docparser/output/json_output.rb |
docparser-0.2.0 | lib/docparser/output/json_output.rb |