Sha256: 95789e5567d0cfb07024233eb6b1daddc195d37f5802866c8194cef94f8c4c4f

Contents?: true

Size: 593 Bytes

Versions: 2

Compression:

Stored size: 593 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.encode(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

2 entries across 2 versions & 1 rubygems

Version Path
siteleaf-2.1.2 lib/siteleaf/source_file.rb
siteleaf-2.1.1 lib/siteleaf/source_file.rb