Class: CarrierWave::Downloader::RemoteFile

Inherits:
Object
  • Object
show all
Defined in:
lib/carrierwave/downloader/remote_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ RemoteFile

Returns a new instance of RemoteFile.



6
7
8
# File 'lib/carrierwave/downloader/remote_file.rb', line 6

def initialize(file)
  @file = file.is_a?(String) ? StringIO.new(file) : file
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



36
37
38
# File 'lib/carrierwave/downloader/remote_file.rb', line 36

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

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



4
5
6
# File 'lib/carrierwave/downloader/remote_file.rb', line 4

def file
  @file
end

Instance Method Details

#original_filenameObject



10
11
12
13
14
15
16
17
# File 'lib/carrierwave/downloader/remote_file.rb', line 10

def original_filename
  filename = filename_from_header || filename_from_uri
  mime_type = MiniMime.lookup_by_content_type(file.content_type)
  unless File.extname(filename).present? || mime_type.blank?
    filename = "#{filename}.#{mime_type.extension}"
  end
  filename
end

#respond_to?(*args) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/carrierwave/downloader/remote_file.rb', line 19

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