class Pirata::Torrent
Attributes
category[R]
id[R]
magnet[R]
title[R]
url[R]
Public Class Methods
find_by_id(id)
click to toggle source
Return a Torrent
object from a corresponding ID
# File lib/pirata/torrent.rb, line 23 def self.find_by_id(id) raise "Invalid torrent ID format. Must be an integer" if id.class != Fixnum url = Pirata.config[:base_url] + "/torrent" + "/#{URI.escape(id.to_s)}" html = self.parse_html(url) results_hash = parse_torrent_page(html) Pirata::Torrent.new(results_hash) end
new(params_hash)
click to toggle source
# File lib/pirata/torrent.rb, line 11 def initialize(params_hash) @params = params_hash @title = @params[:title] @category = @params[:category] @url = @params[:url] @id = @params[:id] @magnet = @params[:magnet] build_getters() end
Public Instance Methods
parse_html(url)
click to toggle source
# File lib/pirata/torrent.rb, line 44 def parse_html(url) response = open(url, :allow_redirections => Pirata.config[:redirect]) Nokogiri::HTML(response) end
update_params!()
click to toggle source
# File lib/pirata/torrent.rb, line 33 def update_params! html = Pirata::Torrent.parse_html(url) updated_params = Pirata::Torrent.parse_torrent_page(html) @params.merge!(updated_params) end