Class: Sabnzbd
- Inherits:
-
Object
- Object
- Sabnzbd
- Includes:
- HTTParty
- Defined in:
- lib/sabnzbd.rb,
lib/sabnzbd/slot.rb,
lib/sabnzbd/utils.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#base_uri ⇒ Object
Returns the value of attribute base_uri.
-
#slots(refresh = false) ⇒ Object
readonly
Returns the value of attribute slots.
-
#utils ⇒ Object
readonly
Returns the value of attribute utils.
Instance Method Summary collapse
- #advanced_queue ⇒ Object
-
#initialize(args = {}) ⇒ Sabnzbd
constructor
A new instance of Sabnzbd.
- #make_request(url = "/api?mode=queue&start=START&limit=LIMIT&output=json&apikey=#{@api_key}") ⇒ Object
- #paused? ⇒ Boolean
- #speed ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Sabnzbd
Returns a new instance of Sabnzbd.
10 11 12 13 14 15 |
# File 'lib/sabnzbd.rb', line 10 def initialize(args={}) @api_key = args[:api_key] || (raise ApiKeyMissing.new, "Api key missing") @base_uri = args[:base_uri] || "localhost:8080" self.class.base_uri @base_uri @utils = Sabnzbd::Utils.new(self) end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
6 7 8 |
# File 'lib/sabnzbd.rb', line 6 def api_key @api_key end |
#base_uri ⇒ Object
Returns the value of attribute base_uri.
6 7 8 |
# File 'lib/sabnzbd.rb', line 6 def base_uri @base_uri end |
#slots(refresh = false) ⇒ Object (readonly)
Returns the value of attribute slots.
7 8 9 |
# File 'lib/sabnzbd.rb', line 7 def slots @slots end |
#utils ⇒ Object (readonly)
Returns the value of attribute utils.
7 8 9 |
# File 'lib/sabnzbd.rb', line 7 def utils @utils end |
Instance Method Details
#advanced_queue ⇒ Object
17 18 19 |
# File 'lib/sabnzbd.rb', line 17 def advanced_queue make_request end |
#make_request(url = "/api?mode=queue&start=START&limit=LIMIT&output=json&apikey=#{@api_key}") ⇒ Object
33 34 35 |
# File 'lib/sabnzbd.rb', line 33 def make_request(url = "/api?mode=queue&start=START&limit=LIMIT&output=json&apikey=#{@api_key}") verify_response( self.class.get(url).parsed_response ) end |
#paused? ⇒ Boolean
21 22 23 |
# File 'lib/sabnzbd.rb', line 21 def paused? make_request["queue"]["paused"] end |
#speed ⇒ Object
25 26 27 |
# File 'lib/sabnzbd.rb', line 25 def speed make_request["queue"]["speed"].strip end |