Path: | lib/violet/response.rb |
Last Update: | Tue Jan 08 22:22:35 +0100 2008 |
this module handle servers messages. Main method/class are Response.parse and Response::Base::ServerRsp (well documented).
you should only use Response.parse with the server‘s message (xml) as argument, it returns a ServerRsp instance from the corresponding class (see all the ServerRsp subclass). with a ServerRsp instance you can use :
>> rsp = Response.parse('<?xml version="1.0" encoding="UTF-8"?><rsp><blacklist nb="2"/><pseudo name="toto"/><pseudo name="titi"/></rsp>') => #<Response::Blacklist:0x2acd8c08f2f8 @xml=<UNDEFINED> ... </>> >> rsp.good? => true >> rsp.has_message? => false >> rsp.message NameError: undefined local variable or method message for #<Response::Blacklist:0x2b1f056afdc0 @xml=<UNDEFINED> ... </>> >> rsp.has_blacklist? => true >> rsp.blacklist => {:nb=>"2"} >> rsp.pseudo => {:name=>"toto"} >> rsp.has_many_pseudos? => true >> rsp.pseudos => [{:name=>"toto"}, {:name=>"titi"}]
if you want to access to the REXML::Document object of a ServerRsp you can either use rsp.xml or use ServerRsp#get_all method.