Sha256: dfc84d4abaf223e8ee03d1443b0f498347c2d493aa3e7e28dc1893139ebc36c3
Contents?: true
Size: 1.06 KB
Versions: 18
Compression:
Stored size: 1.06 KB
Contents
# -*- encoding : utf-8 -*- require 'json' module Workbook module Writers module JsonTableWriter # Output the current workbook to JSON format # # @param [Hash] options # @return [String] json string def to_json options={} JSON.generate(to_array_of_hashes_with_values(options)) end # Output the current workbook to an array_of_hashes_with_values format # # @param [Hash] options # @return [Array<Hash>] array with hashes (comma separated values in a string) def to_array_of_hashes_with_values options={} array_of_hashes = self.collect{|a| a.to_hash_with_values unless a.header?}.compact return array_of_hashes end # Write the current workbook to JSON format # # @param [String] filename # @param [Hash] options see #to_json # @return [String] filename def write_to_json filename="#{title}.json", options={} File.open(filename, 'w') {|f| f.write(to_json(options)) } return filename end end end end
Version data entries
18 entries across 18 versions & 1 rubygems