Class: Leecher::Gheed::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/leecher/gheed/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Client

Returns a new instance of Client.



10
11
12
# File 'lib/leecher/gheed/client.rb', line 10

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/leecher/gheed/client.rb', line 8

def config
  @config
end

Instance Method Details

#new_resource(path) ⇒ Object



15
16
17
18
# File 'lib/leecher/gheed/client.rb', line 15

def new_resource(path)
  uri = URI.join(config.uri, path).to_s
  RestClient::Resource.new(uri, config.username, config.password)
end

#state_change(download, state) ⇒ Object



20
21
22
23
24
# File 'lib/leecher/gheed/client.rb', line 20

def state_change(download, state)
  req = new_resource("/leecher/state_change")
  res = req.put({ "uri" => download, "state" => state })
  MultiJson.decode(res)
end

#status_update(params) ⇒ Object



26
27
28
29
30
# File 'lib/leecher/gheed/client.rb', line 26

def status_update(params)
  req = new_resource("/leecher/status_update")
  res = req.post({ "status" => params })
  MultiJson.decode(res)
end