Class: XBMC::Connection
Overview
Connection class used to specify credentials and proxy settings
Instance Attribute Summary collapse
-
#host ⇒ Object
network hostname.
-
#password ⇒ Object
password.
-
#port ⇒ Object
network port.
-
#proxy ⇒ Object
proxy getter.
-
#user ⇒ Object
username.
Instance Method Summary collapse
-
#exec(command) ⇒ Object
:nodoc:.
-
#initialize(host, port = nil, user = nil, pass = nil) ⇒ Connection
constructor
A new instance of Connection.
Constructor Details
#initialize(host, port = nil, user = nil, pass = nil) ⇒ Connection
Returns a new instance of Connection.
140 141 142 143 144 145 |
# File 'lib/ruby-xbmc.rb', line 140 def initialize(host, port=nil, user=nil, pass=nil) @host=host @port=port @user=user @password=pass end |
Instance Attribute Details
#password ⇒ Object
password
135 136 137 |
# File 'lib/ruby-xbmc.rb', line 135 def password @password end |
#proxy ⇒ Object
proxy getter
148 149 150 151 |
# File 'lib/ruby-xbmc.rb', line 148 def proxy return @proxy unless @proxy.nil? ENV["proxy"] end |
Instance Method Details
#exec(command) ⇒ Object
:nodoc:
153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/ruby-xbmc.rb', line 153 def exec(command) #:nodoc: command.rstrip! command += "()" if command[-1,1] != ")" url = SCHEME + "://" + host + ":" + port + CMDPATH + command begin return open(url,"r",http_opts) rescue OpenURI::HTTPError => e if e.io.status.first.to_i == 401 raise (user.nil? ? UnauthenticatedError.new : WrongCredentialsError.new ) end raise e end end |