Class: DownloadTV::LinkGrabber
- Inherits:
-
Object
- Object
- DownloadTV::LinkGrabber
- Defined in:
- lib/download_tv/linkgrabber.rb
Overview
Interface for the grabbers
Direct Known Subclasses
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #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 12 13 |
# File 'lib/download_tv/linkgrabber.rb', line 9 def initialize(url) @url = url @agent = Mechanize.new @agent.user_agent = DownloadTV::USER_AGENT 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
#get_links(_show) ⇒ Object
28 29 30 |
# File 'lib/download_tv/linkgrabber.rb', line 28 def get_links(_show) raise NotImplementedError end |
#online? ⇒ Boolean
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/download_tv/linkgrabber.rb', line 15 def online? @agent.read_timeout = 2 url = if @url.include? '%s' format(@url, 'test') else @url end @agent.head(url) true rescue Mechanize::ResponseCodeError, Net::HTTP::Persistent::Error, Errno::ECONNRESET false end |