class TorrentRSS::Torrent
Attributes
id[RW]
summary[RW]
title[RW]
url[RW]
Public Class Methods
from_entry(entry)
click to toggle source
# File lib/torrent_rss/torrent.rb, line 5 def self.from_entry entry torrent = new [:id, :url, :title, :summary].each do |attr| torrent.send "#{attr}=", entry.send("#{attr}") end torrent end
new()
click to toggle source
# File lib/torrent_rss/torrent.rb, line 15 def initialize @connection = Faraday.new do |builder| builder.adapter Faraday.default_adapter end end
Public Instance Methods
download(directory)
click to toggle source
# File lib/torrent_rss/torrent.rb, line 21 def download directory response = @connection.get @url if response.success? filename = response.headers['content-disposition'].match(/filename=\"(.+)\"/)[1] File.write "#{directory}/#{filename}", response.body end response.success? end