module Workbook::Writers::JsonTableWriter
Public Instance Methods
to_array_of_hashes_with_values(options={})
click to toggle source
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)
# File lib/workbook/writers/json_table_writer.rb, line 22 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
to_json(options={})
click to toggle source
Output the current workbook to JSON format
@param [Hash] options @return [String] json string
# File lib/workbook/writers/json_table_writer.rb, line 14 def to_json options={} JSON.generate(to_array_of_hashes_with_values(options)) end
write_to_json(filename="
click to toggle source
Write the current workbook to JSON format
@param [String] filename @param [Hash] options see to_json
@return [String] filename
# File lib/workbook/writers/json_table_writer.rb, line 32 def write_to_json filename="#{title}.json", options={} File.open(filename, 'w') {|f| f.write(to_json(options)) } return filename end