Class: Nzbmatrix::SearchResult
- Inherits:
-
Object
- Object
- Nzbmatrix::SearchResult
- Defined in:
- lib/nzbmatrix/search_result.rb
Instance Attribute Summary collapse
-
#category ⇒ Object
Returns the value of attribute category.
-
#comments ⇒ Object
Returns the value of attribute comments.
-
#group ⇒ Object
Returns the value of attribute group.
-
#hits ⇒ Object
Returns the value of attribute hits.
-
#id ⇒ Object
Returns the value of attribute id.
-
#image_url ⇒ Object
Returns the value of attribute image_url.
-
#index_date ⇒ Object
Returns the value of attribute index_date.
-
#language ⇒ Object
Returns the value of attribute language.
-
#link ⇒ Object
Returns the value of attribute link.
-
#name ⇒ Object
Returns the value of attribute name.
-
#region ⇒ Object
Returns the value of attribute region.
-
#size ⇒ Object
Returns the value of attribute size.
-
#usenet_date ⇒ Object
Returns the value of attribute usenet_date.
-
#weblink ⇒ Object
Returns the value of attribute weblink.
Instance Method Summary collapse
- #download(path = nil) ⇒ Object
- #has_image? ⇒ Boolean
- #has_nfo? ⇒ Boolean
-
#initialize(api_response, client) ⇒ SearchResult
constructor
A new instance of SearchResult.
Constructor Details
#initialize(api_response, client) ⇒ SearchResult
Returns a new instance of SearchResult.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/nzbmatrix/search_result.rb', line 22 def initialize(api_response, client) @client = client @id = api_response["NZBID"].to_i @name = api_response["NZBNAME"] @link = api_response["LINK"] @size = api_response["SIZE"].to_f @index_date = Time.parse(api_response["INDEX_DATE"]) rescue nil @usenet_date = Time.parse(api_response["USENET_DATE"]) rescue nil @category = api_response["CATEGORY"] @group = api_response["GROUP"] @comments = api_response["COMMENTS"].to_i @hits = api_response["HITS"].to_i @nfo = api_response["NFO"] == "yes" @weblink = api_response["WEBLINK"] @language = api_response["LANGUAGE"] @image_url = api_response["IMAGE"] @region = api_response["REGION"].to_i end |
Instance Attribute Details
#category ⇒ Object
Returns the value of attribute category.
13 14 15 |
# File 'lib/nzbmatrix/search_result.rb', line 13 def category @category end |
#comments ⇒ Object
Returns the value of attribute comments.
15 16 17 |
# File 'lib/nzbmatrix/search_result.rb', line 15 def comments @comments end |
#group ⇒ Object
Returns the value of attribute group.
14 15 16 |
# File 'lib/nzbmatrix/search_result.rb', line 14 def group @group end |
#hits ⇒ Object
Returns the value of attribute hits.
16 17 18 |
# File 'lib/nzbmatrix/search_result.rb', line 16 def hits @hits end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/nzbmatrix/search_result.rb', line 7 def id @id end |
#image_url ⇒ Object
Returns the value of attribute image_url.
19 20 21 |
# File 'lib/nzbmatrix/search_result.rb', line 19 def image_url @image_url end |
#index_date ⇒ Object
Returns the value of attribute index_date.
11 12 13 |
# File 'lib/nzbmatrix/search_result.rb', line 11 def index_date @index_date end |
#language ⇒ Object
Returns the value of attribute language.
18 19 20 |
# File 'lib/nzbmatrix/search_result.rb', line 18 def language @language end |
#link ⇒ Object
Returns the value of attribute link.
9 10 11 |
# File 'lib/nzbmatrix/search_result.rb', line 9 def link @link end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/nzbmatrix/search_result.rb', line 8 def name @name end |
#region ⇒ Object
Returns the value of attribute region.
20 21 22 |
# File 'lib/nzbmatrix/search_result.rb', line 20 def region @region end |
#size ⇒ Object
Returns the value of attribute size.
10 11 12 |
# File 'lib/nzbmatrix/search_result.rb', line 10 def size @size end |
#usenet_date ⇒ Object
Returns the value of attribute usenet_date.
12 13 14 |
# File 'lib/nzbmatrix/search_result.rb', line 12 def usenet_date @usenet_date end |
#weblink ⇒ Object
Returns the value of attribute weblink.
17 18 19 |
# File 'lib/nzbmatrix/search_result.rb', line 17 def weblink @weblink end |
Instance Method Details
#download(path = nil) ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/nzbmatrix/search_result.rb', line 42 def download(path = nil) path ||= Dir.pwd path = File.(path) FileUtils.mkdir_p(path) nzb = @client.download(id) File.open(File.join(path, "#{name}.nzb"), "w") { |f| f.write(nzb) } id end |
#has_image? ⇒ Boolean
57 58 59 |
# File 'lib/nzbmatrix/search_result.rb', line 57 def has_image? !!@image_url end |
#has_nfo? ⇒ Boolean
53 54 55 |
# File 'lib/nzbmatrix/search_result.rb', line 53 def has_nfo? !!@nfo end |