class Decidim::Exporters::ExportData
Holds the result of an export.
Attributes
extension[R]
Public Class Methods
new(data, extension)
click to toggle source
Initializes an `ExportData` with the RAW data and the extension.
# File lib/decidim/exporters/export_data.rb, line 10 def initialize(data, extension) @data = data @extension = extension end
Public Instance Methods
filename(prefix = "export", options = {})
click to toggle source
Generates a filename based on the export creation date.
prefix - A string value for the filename prefix. (default: 'export') options - An optional hash of options
* extension - Whether the filename should include the extension or not.
Returns a String with the filename of the export.
# File lib/decidim/exporters/export_data.rb, line 29 def filename(prefix = "export", options = {}) options[:extension] = !options[:extension].nil? ? options[:extension] : true result = "#{prefix}-#{I18n.l(Time.zone.today, format: :default)}-#{Time.now.seconds_since_midnight.to_i}" result += ".#{extension}" if options[:extension] result end
read()
click to toggle source
Gives back the raw data of the export.
Returns a String with the result of the export.
# File lib/decidim/exporters/export_data.rb, line 18 def read @data end