Module: Workbook::Writers::JsonTableWriter
- Included in:
- Table
- Defined in:
- lib/workbook/writers/json_table_writer.rb
Instance Method Summary collapse
-
#to_array_of_hashes_with_values(options = {}) ⇒ Array<Hash>
Output the current workbook to an array_of_hashes_with_values format.
-
#to_json(options = {}) ⇒ String
Output the current workbook to JSON format.
-
#write_to_json(filename = "#{title}.json", options = {}) ⇒ String
Write the current workbook to JSON format.
Instance Method Details
#to_array_of_hashes_with_values(options = {}) ⇒ Array<Hash>
Output the current workbook to an array_of_hashes_with_values format
22 23 24 25 |
# File 'lib/workbook/writers/json_table_writer.rb', line 22 def to_array_of_hashes_with_values ={} array_of_hashes = self.collect{|a| a.to_hash_with_values unless a.header?}.compact return array_of_hashes end |
#to_json(options = {}) ⇒ String
Output the current workbook to JSON format
14 15 16 |
# File 'lib/workbook/writers/json_table_writer.rb', line 14 def to_json ={} JSON.generate(to_array_of_hashes_with_values()) end |
#write_to_json(filename = "#{title}.json", options = {}) ⇒ String
Write the current workbook to JSON format
32 33 34 35 |
# File 'lib/workbook/writers/json_table_writer.rb', line 32 def write_to_json filename="#{title}.json", ={} File.open(filename, 'w') {|f| f.write(to_json()) } return filename end |