Class: Anyfetch::OpenURI

Inherits:
Object
  • Object
show all
Defined in:
lib/anyfetch/open_uri.rb

Direct Known Subclasses

FTP, HTTP

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ OpenURI

Returns a new instance of OpenURI.

Raises:

  • (NotImplementedError)


6
7
8
# File 'lib/anyfetch/open_uri.rb', line 6

def initialize(*args)
  raise NotImplementedError
end

Instance Method Details

#openObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/anyfetch/open_uri.rb', line 10

def open
  file = ::OpenURI.open_uri(@uri, @options)

  if file.is_a?(StringIO)
    file = to_tempfile(file)
  end

  file.extend(OriginalFilename::ContentType)
  file
end