Class: CarrierWave::Uploader::Download::RemoteFile

Inherits:
Object
  • Object
show all
Defined in:
lib/carrierwave/uploader/download.rb

Instance Method Summary collapse

Constructor Details

#initialize(uri, remote_headers = {}) ⇒ RemoteFile

Returns a new instance of RemoteFile.



13
14
15
16
17
# File 'lib/carrierwave/uploader/download.rb', line 13

def initialize(uri, remote_headers = {})
  @uri = uri
  @remote_headers = remote_headers
  @file = nil
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, &block) ⇒ Object (private)



63
64
65
# File 'lib/carrierwave/uploader/download.rb', line 63

def method_missing(*args, &block)
  file.send(*args, &block)
end

Instance Method Details

#http?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/carrierwave/uploader/download.rb', line 32

def http?
  @uri.scheme =~ /^https?$/
end

#original_filenameObject



19
20
21
22
23
24
25
26
# File 'lib/carrierwave/uploader/download.rb', line 19

def original_filename
  filename = filename_from_header || filename_from_uri
  mime_type = MIME::Types[file.content_type].first
  unless File.extname(filename).present? || mime_type.blank?
    filename = "#{filename}.#{mime_type.extensions.first}"
  end
  filename
end

#respond_to?(*args) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/carrierwave/uploader/download.rb', line 28

def respond_to?(*args)
  super or file.respond_to?(*args)
end