Class: DownloadTV::LinkGrabber

Inherits:
Object
  • Object
show all
Defined in:
lib/download_tv/linkgrabber.rb

Overview

Interface for the grabbers

Direct Known Subclasses

Eztv, ThePirateBay, TorrentGalaxy, Torrentz

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#urlObject (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

#agentObject



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

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/download_tv/linkgrabber.rb', line 32

def get_links(_show)
  raise NotImplementedError
end

#online?Boolean

Returns:

  • (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