Class: TorrentSearch::Services::Download
- Inherits:
-
Object
- Object
- TorrentSearch::Services::Download
- Defined in:
- lib/torrent_search/services/download.rb
Instance Method Summary collapse
- #filename ⇒ Object
-
#initialize(path, torrent) ⇒ Download
constructor
A new instance of Download.
- #perform(view) ⇒ Object
- #success? ⇒ Boolean
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
#filename ⇒ Object
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
20 21 22 |
# File 'lib/torrent_search/services/download.rb', line 20 def success? response.code == 200 end |