Sha256: d9a00e9e3ac88e4d92f7af9c240921adc4e9efe33885deb21f371c67f430f6bd

Contents?: true

Size: 745 Bytes

Versions: 10

Compression:

Stored size: 745 Bytes

Contents

module Siteleaf
  class File < Entity
    
    attr_accessor :file, :filename, :path, :collection_path, :site_id, :user_id
    attr_reader :id, :basename, :directory, :url, :download_url, :thumbnail_url, :content_type, :filesize, :sha, :created_at, :updated_at
    
    def create_endpoint
      ::File.join("sites", site_id, "collections", collection_identifier, "files")
    end
    
    def site
      Site.find(site_id) if site_id
    end
    
    def collection
      Collection.find(collection_identifier)
    end
    
    def collection_identifier
      collection_path || (directory && directory.match(/_(.*)/).try(:last))
    end
    
    def to_file
      SourceFile.new(site_id: site_id, name: filename).to_file
    end
    
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
siteleaf-2.3.0 lib/siteleaf/file.rb
siteleaf-2.2.1 lib/siteleaf/file.rb
siteleaf-2.2.0 lib/siteleaf/file.rb
siteleaf-2.1.2 lib/siteleaf/file.rb
siteleaf-2.1.1 lib/siteleaf/file.rb
siteleaf-2.1.0 lib/siteleaf/file.rb
siteleaf-2.0.2 lib/siteleaf/file.rb
siteleaf-2.0.1 lib/siteleaf/file.rb
siteleaf-2.0.0 lib/siteleaf/file.rb
siteleaf-2.0.0.pre.beta9 lib/siteleaf/file.rb