module DinosaurCatalog::JsonExport

Public Instance Methods

convert_object_to_array(object) click to toggle source
# File lib/dinosaur_catalog/json_export.rb, line 8
def convert_object_to_array(object)
  object.inject([]) { |array, attribute| array << attribute.to_hash }
end
convert_to_json(ruby_object) click to toggle source
# File lib/dinosaur_catalog/json_export.rb, line 3
def convert_to_json(ruby_object)
  array_of_objects = convert_object_to_array(ruby_object)
  File.open("json_export.json", "w") { |f| f.puts JSON.generate(array_of_objects) }
end