Class: TorrentSearch::Services::Download

Inherits:
Object
  • Object
show all
Defined in:
lib/torrent_search/services/download.rb

Instance Method Summary collapse

Constructor Details

#initialize(path, torrent) ⇒ Download

Returns a new instance of Download.



6
7
8
9
# File 'lib/torrent_search/services/download.rb', line 6

def initialize(path, torrent)
  @path = path
  @torrent = torrent
end

Instance Method Details

#filenameObject



24
25
26
# File 'lib/torrent_search/services/download.rb', line 24

def filename
  File.join(@path, "#{@torrent.filename}.torrent")
end

#perform(view) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/torrent_search/services/download.rb', line 11

def perform(view)
  if success?
    save!
    view.success
  else
    view.failure response, @torrent.href
  end
end

#success?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/torrent_search/services/download.rb', line 20

def success?
  response.code == 200
end