Class: Decidim::Exporters::ExportData
- Inherits:
 - 
      Object
      
        
- Object
 - Decidim::Exporters::ExportData
 
 
- Defined in:
 - lib/decidim/exporters/export_data.rb
 
Overview
Holds the result of an export.
Instance Attribute Summary collapse
- 
  
    
      #extension  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute extension.
 
Instance Method Summary collapse
- 
  
    
      #filename(prefix = "export", options = {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Generates a filename based on the export creation date.
 - 
  
    
      #initialize(data, extension)  ⇒ ExportData 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
Initializes an ‘ExportData` with the RAW data and the extension.
 - 
  
    
      #read  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Gives back the raw data of the export.
 
Constructor Details
#initialize(data, extension) ⇒ ExportData
Initializes an ‘ExportData` with the RAW data and the extension.
      10 11 12 13  | 
    
      # File 'lib/decidim/exporters/export_data.rb', line 10 def initialize(data, extension) @data = data @extension = extension end  | 
  
Instance Attribute Details
#extension ⇒ Object (readonly)
Returns the value of attribute extension.
      7 8 9  | 
    
      # File 'lib/decidim/exporters/export_data.rb', line 7 def extension @extension end  | 
  
Instance Method Details
#filename(prefix = "export", options = {}) ⇒ Object
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.
      29 30 31 32 33 34  | 
    
      # File 'lib/decidim/exporters/export_data.rb', line 29 def filename(prefix = "export", = {}) [:extension] = [:extension].nil? ? true : [:extension] result = "#{prefix}-#{I18n.l(Time.zone.today, format: :default)}-#{Time.now.seconds_since_midnight.to_i}" result += ".#{extension}" if [:extension] result end  | 
  
#read ⇒ Object
Gives back the raw data of the export.
Returns a String with the result of the export.
      18 19 20  | 
    
      # File 'lib/decidim/exporters/export_data.rb', line 18 def read @data end  |