Sha256: 00d2779f5bd3b32d30fa8be1380c401cbd8c368d5dcfe0299585615359ed9a18

Contents?: true

Size: 605 Bytes

Versions: 3

Compression:

Stored size: 605 Bytes

Contents

module Siteleaf
  class SourceFile < Entity

    attr_accessor :file, :name, :site_id
    attr_reader :name, :url, :download_url, :type, :filesize, :sha, :created_at, :updated_at, :user_id

    def create_endpoint
      uri = URI::Parser.new.escape(identifier)
      uri = uri.gsub('[', '%5B').gsub(']', '%5D') # workaround for https://bugs.ruby-lang.org/issues/12235
      ::File.join('sites', site_id, 'source', uri)
    end

    def entity_endpoint
      create_endpoint
    end

    def identifier
      name
    end

    def to_file
      Client.get("#{entity_endpoint}?download")
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
siteleaf-2.3.0 lib/siteleaf/source_file.rb
siteleaf-2.2.1 lib/siteleaf/source_file.rb
siteleaf-2.2.0 lib/siteleaf/source_file.rb