Sha256: 2a71847eac7c61f00f81eab379e6d0d591e827375988c96b5a879cb47117a13d

Contents?: true

Size: 1020 Bytes

Versions: 1

Compression:

Stored size: 1020 Bytes

Contents

# require "eitil_integrate/application_exporter/store_file"

require "eitil_integrate/application_exporter/initialize"
require "eitil_core/setters/set_ivars"

module EitilIntegrate::RubyXL
  class ApplicationExporter
    
    attr_accessor :storage_path

    private

    def save_file
      set_ivars :storage_path
      save_book
      run_after_save_effects
      @storage_path
    end

    def set_storage_path
      "#{Rails.root}/data/#{file_name}"
    end

    def file_name
      "#{file_tile}|#{file_timestamp}.#{file_extension}"
    end

    def file_tile
      @file_title || self.class.name.snakecase
    end

    def file_timestamp
      @file_timestamp || Time.now.strftime("%Y-%m-%d|%H-%M-%S")
    end

    def file_extension
      @file_extension || "xlsx"
    end

    def save_book
      book.write @storage_path
    end

    def run_after_save_effects
      # nil fallback for if the application class (which inherits from ApplicationExporter) has no method #run_after_save_effects
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eitil-2.0.6 eitil_integrate/lib/eitil_integrate/application_exporter/store_file.rb