Class: Nzbs::NZB

Inherits:
Object
  • Object
show all
Defined in:
lib/sites/nzbs/nzb.rb

Constant Summary collapse

URL =
'http://www.nzbs.org'
DAYS_BY_PAGE =
5

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ NZB

Returns a new instance of NZB.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sites/nzbs/nzb.rb', line 18

def initialize(options = {})
  @options = options
  @options[:age] ||= DAYS_BY_PAGE
  @options[:pages] ||= ((@options[:age].to_f + DAYS_BY_PAGE) / DAYS_BY_PAGE).ceil

  @nzb_urls = []
  @nzbs = []

  (1..(@options[:pages].to_i)).each do |page|
    @nzb_urls << "#{URL}/index.php?action=browse&catid=4&page=#{(page)}"
  end
  
  
  parse_nzbs
end

Instance Attribute Details

#agentObject

Returns the value of attribute agent.



16
17
18
# File 'lib/sites/nzbs/nzb.rb', line 16

def agent
  @agent
end

#nzbsObject

Returns the value of attribute nzbs.



16
17
18
# File 'lib/sites/nzbs/nzb.rb', line 16

def nzbs
  @nzbs
end

Instance Method Details

#download(movie) ⇒ Object



34
35
36
# File 'lib/sites/nzbs/nzb.rb', line 34

def download(movie)
  @agent.get_file(movie.nzb_link)
end