Module: Resync::Client::Mixins::Downloadable

Includes:
ClientDelegator
Included in:
ZippedResource, Link, Resource
Defined in:
lib/resync/client/mixins/downloadable.rb

Overview

A downloadable resource or link.

Instance Attribute Summary

Attributes included from ClientDelegator

#client_delegate

Instance Method Summary collapse

Methods included from ClientDelegator

#client, #client=

Instance Method Details

#download_to_file(path) ⇒ Object

Delegates to Resync::Client#download_to_file to download the contents of :uri to the specified path. Subsequent calls wiill download the contents again, potentially overwriting the file if given the same path.

Parameters:

  • path (String)

    the path to download to



38
39
40
# File 'lib/resync/client/mixins/downloadable.rb', line 38

def download_to_file(path)
  client.download_to_file(uri: uri, path: path)
end

#download_to_temp_fileObject

Delegates to Resync::Client#download_to_temp_file to download the contents of :uri to a file. Subsequent calls will download the contents again, each time to a fresh temporary file.



29
30
31
# File 'lib/resync/client/mixins/downloadable.rb', line 29

def download_to_temp_file # rubocop:disable Style/AccessorMethodName
  client.download_to_temp_file(uri)
end

#getObject

Delegates to Resync::Client#get to get the contents of this :uri. The downloaded content will only be downloaded once; subsequent calls to this method will return the cached content.



22
23
24
# File 'lib/resync/client/mixins/downloadable.rb', line 22

def get # rubocop:disable Style/AccessorMethodName
  @content ||= client.get(uri)
end

#get_and_parseObject

Delegates to Resync::Client#get_and_parse to get the contents of :uri as a ResourceSync document. The downloaded, parsed document will only be downloaded once; subsequent calls to this method will return the cached document.



15
16
17
# File 'lib/resync/client/mixins/downloadable.rb', line 15

def get_and_parse # rubocop:disable Style/AccessorMethodName
  @parsed_content ||= client.get_and_parse(uri)
end