Class: DownloadTV::LinkGrabber
- Inherits:
-
Object
- Object
- DownloadTV::LinkGrabber
- Defined in:
- lib/download_tv/linkgrabber.rb
Overview
Interface for the grabbers
Direct Known Subclasses
Eztv, ThePirateBay, ThePirateBayAPI, TorrentGalaxy, Torrentz
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #agent ⇒ Object
- #get_links(_show) ⇒ Object
-
#initialize(url) ⇒ LinkGrabber
constructor
A new instance of LinkGrabber.
- #online? ⇒ Boolean
Constructor Details
#initialize(url) ⇒ LinkGrabber
Returns a new instance of LinkGrabber.
9 10 11 |
# File 'lib/download_tv/linkgrabber.rb', line 9 def initialize(url) @url = url end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/download_tv/linkgrabber.rb', line 7 def url @url end |
Instance Method Details
#agent ⇒ Object
13 14 15 16 17 18 |
# File 'lib/download_tv/linkgrabber.rb', line 13 def agent @agent ||= Mechanize.new do |a| a.user_agent = DownloadTV::USER_AGENT a.read_timeout = 10 end end |
#get_links(_show) ⇒ Object
32 33 34 |
# File 'lib/download_tv/linkgrabber.rb', line 32 def get_links(_show) raise NotImplementedError end |
#online? ⇒ Boolean
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/download_tv/linkgrabber.rb', line 20 def online? url = if @url.include? '%s' format(@url, 'test') else @url end agent.head(url) true rescue StandardError false end |