Class: Sabnzbd

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/sabnzbd.rb,
lib/sabnzbd/slot.rb,
lib/sabnzbd/utils.rb

Defined Under Namespace

Classes: Slot, Utils

Instance Attribute Summary collapse

Instance Method Summary collapse

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_keyObject

Returns the value of attribute api_key.



6
7
8
# File 'lib/sabnzbd.rb', line 6

def api_key
  @api_key
end

#base_uriObject

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

#utilsObject (readonly)

Returns the value of attribute utils.



7
8
9
# File 'lib/sabnzbd.rb', line 7

def utils
  @utils
end

Instance Method Details

#advanced_queueObject



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

Returns:

  • (Boolean)


21
22
23
# File 'lib/sabnzbd.rb', line 21

def paused?
  make_request["queue"]["paused"]
end

#speedObject



25
26
27
# File 'lib/sabnzbd.rb', line 25

def speed
  make_request["queue"]["speed"].strip
end