Sha256: 7f8266e7d6d2e0a66a6dad23e6f41764205a5c2e94f542eae7a308657f7a6b01
Contents?: true
Size: 722 Bytes
Versions: 1
Compression:
Stored size: 722 Bytes
Contents
require "httparty" module TorrentSearch module Services class Download def initialize(path, torrent) @path = path @torrent = torrent end def perform(view) if success? save! view.success else view.failure response, @torrent.href end end private def success? response.code == 200 end def filename File.join(@path, "#{@torrent.filename}.torrent") end def save! File.open(filename, "wb") do |file| file.write response.parsed_response end end def response @response ||= HTTParty.get(@torrent.href) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
torrent_search-0.0.2 | lib/torrent_search/services/download.rb |