Class: Mamba::Client
- Inherits:
-
Object
- Object
- Mamba::Client
- Defined in:
- lib/mamba/client.rb
Instance Attribute Summary collapse
-
#accounting ⇒ Object
readonly
Returns the value of attribute accounting.
-
#calls ⇒ Object
readonly
Returns the value of attribute calls.
Instance Method Summary collapse
- #call(method, *params) ⇒ Object
-
#initialize(server, user = nil, password = nil, accounting = false, timeout = 30) ⇒ Client
constructor
A new instance of Client.
- #login(user, password) ⇒ Object
- #logout ⇒ Object
Constructor Details
#initialize(server, user = nil, password = nil, accounting = false, timeout = 30) ⇒ Client
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/mamba/client.rb', line 7 def initialize(server,user=nil,password=nil,accounting=false,timeout=30) @client = XMLRPC::Client.new2("https://#{server}/rpc/api",nil,timeout) if accounting @accounting = true @calls = Hash.new(0) end login(user,password) if ! (user.nil? or password.nil?) end |
Instance Attribute Details
#accounting ⇒ Object (readonly)
Returns the value of attribute accounting.
5 6 7 |
# File 'lib/mamba/client.rb', line 5 def accounting @accounting end |
#calls ⇒ Object (readonly)
Returns the value of attribute calls.
5 6 7 |
# File 'lib/mamba/client.rb', line 5 def calls @calls end |
Instance Method Details
#call(method, *params) ⇒ Object
26 27 28 |
# File 'lib/mamba/client.rb', line 26 def call(method,*params) _call(method,@key,*params) end |
#login(user, password) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/mamba/client.rb', line 18 def login(user,password) @key = @client.call('auth.login',user,password) _account('auth.login') # return true if we were successful true end |
#logout ⇒ Object
30 31 32 |
# File 'lib/mamba/client.rb', line 30 def logout _call('auth.logout',@key) end |