Class: INWX::Domrobot
- Inherits:
-
Object
- Object
- INWX::Domrobot
- Defined in:
- lib/inwx/domrobot.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#cookie ⇒ Object
Returns the value of attribute cookie.
Instance Method Summary collapse
- #call(object, method, params = {}) ⇒ Object
- #getCookie ⇒ Object
-
#initialize(address) ⇒ Domrobot
constructor
A new instance of Domrobot.
- #login(username = false, password = false, language = 'en') ⇒ Object
- #logout ⇒ Object
- #setCookie(cookie) ⇒ Object
Constructor Details
#initialize(address) ⇒ Domrobot
Returns a new instance of Domrobot.
7 8 9 10 11 |
# File 'lib/inwx/domrobot.rb', line 7 def initialize(address) @cookie = "" # Create a new client instance @client = XMLRPC::Client.new(address,"/xmlrpc/","443", nil, nil, nil, nil, true, 100) end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
5 6 7 |
# File 'lib/inwx/domrobot.rb', line 5 def client @client end |
#cookie ⇒ Object
Returns the value of attribute cookie.
5 6 7 |
# File 'lib/inwx/domrobot.rb', line 5 def @cookie end |
Instance Method Details
#call(object, method, params = {}) ⇒ Object
46 47 48 49 50 |
# File 'lib/inwx/domrobot.rb', line 46 def call(object, method, params = {}) client. = getCookie() # Call the remote method client.call(object+"."+method, params) end |
#getCookie ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/inwx/domrobot.rb', line 34 def getCookie() if self..length > 2 return self. end if File.exist?("domrobot.tmp") fp = File.new("domrobot.tmp", "r") = fp.read() fp.close return end end |
#login(username = false, password = false, language = 'en') ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/inwx/domrobot.rb', line 13 def login(username = false, password = false, language = 'en') params = { :user => username, :pass => password, 'lang' => language } ret = call("account","login",params) = client. unless .nil? || .length <= 2 setCookie() end return ret end |
#logout ⇒ Object
23 24 25 |
# File 'lib/inwx/domrobot.rb', line 23 def logout() call("account","logout") end |
#setCookie(cookie) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/inwx/domrobot.rb', line 27 def setCookie() self. = fp = File.new("domrobot.tmp", "w") fp.write() fp.close end |