Class: Shrine::Storage::Url::Downloader

Inherits:
Object
  • Object
show all
Defined in:
lib/shrine/storage/url.rb

Constant Summary collapse

SUPPORTED_TOOLS =
[:down, :wget]

Instance Method Summary collapse

Constructor Details

#initialize(tool) ⇒ Downloader

Returns a new instance of Downloader.

Raises:

  • (ArgumentError)


54
55
56
57
58
# File 'lib/shrine/storage/url.rb', line 54

def initialize(tool)
  raise ArgumentError, "unsupported downloading tool: #{tool}" unless SUPPORTED_TOOLS.include?(tool)

  @tool = tool
end

Instance Method Details

#download(url) ⇒ Object



60
61
62
# File 'lib/shrine/storage/url.rb', line 60

def download(url)
  send(:"download_with_#{@tool}", url)
end

#open(url) ⇒ Object



64
65
66
# File 'lib/shrine/storage/url.rb', line 64

def open(url)
  send(:"open_with_#{@tool}", url)
end