Class: Transmission::RPC::Connector
- Inherits:
-
Object
- Object
- Transmission::RPC::Connector
- Defined in:
- lib/transmission/rpc/connector.rb
Defined Under Namespace
Classes: AuthError, ConnectionError
Instance Attribute Summary collapse
-
#credentials ⇒ Object
Returns the value of attribute credentials.
-
#host ⇒ Object
Returns the value of attribute host.
-
#path ⇒ Object
Returns the value of attribute path.
-
#port ⇒ Object
Returns the value of attribute port.
-
#response ⇒ Object
Returns the value of attribute response.
-
#session_id ⇒ Object
Returns the value of attribute session_id.
-
#ssl ⇒ Object
Returns the value of attribute ssl.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Connector
constructor
A new instance of Connector.
- #post(params = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Connector
Returns a new instance of Connector.
12 13 14 15 16 17 18 19 |
# File 'lib/transmission/rpc/connector.rb', line 12 def initialize( = {}) @host = [:host] || 'localhost' @port = [:port] || 9091 @ssl = !![:ssl] @credentials = [:credentials] || nil @path = [:path] || '/transmission/rpc' @session_id = [:session_id] || '' end |
Instance Attribute Details
#credentials ⇒ Object
Returns the value of attribute credentials.
10 11 12 |
# File 'lib/transmission/rpc/connector.rb', line 10 def credentials @credentials end |
#host ⇒ Object
Returns the value of attribute host.
10 11 12 |
# File 'lib/transmission/rpc/connector.rb', line 10 def host @host end |
#path ⇒ Object
Returns the value of attribute path.
10 11 12 |
# File 'lib/transmission/rpc/connector.rb', line 10 def path @path end |
#port ⇒ Object
Returns the value of attribute port.
10 11 12 |
# File 'lib/transmission/rpc/connector.rb', line 10 def port @port end |
#response ⇒ Object
Returns the value of attribute response.
10 11 12 |
# File 'lib/transmission/rpc/connector.rb', line 10 def response @response end |
#session_id ⇒ Object
Returns the value of attribute session_id.
10 11 12 |
# File 'lib/transmission/rpc/connector.rb', line 10 def session_id @session_id end |
#ssl ⇒ Object
Returns the value of attribute ssl.
10 11 12 |
# File 'lib/transmission/rpc/connector.rb', line 10 def ssl @ssl end |
Instance Method Details
#post(params = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/transmission/rpc/connector.rb', line 21 def post(params = {}) response = connection.post do |req| req.url @path req.headers['X-Transmission-Session-Id'] = @session_id req.headers['Content-Type'] = 'application/json' req.body = JSON.generate(params) end handle_response response, params end |