Module: Down::Wget::DownloadedFile

Defined in:
lib/down/wget.rb

Overview

Adds additional attributes to the Tempfile returned in #download.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#headersObject

Returns the value of attribute headers.



234
235
236
# File 'lib/down/wget.rb', line 234

def headers
  @headers
end

#urlObject

Returns the value of attribute url.



234
235
236
# File 'lib/down/wget.rb', line 234

def url
  @url
end

Instance Method Details

#charsetObject



245
246
247
# File 'lib/down/wget.rb', line 245

def charset
  headers["Content-Type"].to_s[/;\s*charset=([^;]+)/i, 1]
end

#content_typeObject



241
242
243
# File 'lib/down/wget.rb', line 241

def content_type
  headers["Content-Type"].to_s.split(";").first
end

#original_filenameObject



236
237
238
239
# File 'lib/down/wget.rb', line 236

def original_filename
  Utils.filename_from_content_disposition(headers["Content-Disposition"]) ||
  Utils.filename_from_path(URI.parse(url).path)
end