Class: FireEagle::Response
- Inherits:
-
Object
- Object
- FireEagle::Response
- Defined in:
- lib/fireeagle/response.rb
Instance Method Summary collapse
-
#initialize(doc) ⇒ Response
constructor
Parses the XML response from FireEagle.
-
#locations ⇒ Object
A Location array.
-
#success? ⇒ Boolean
does the response indicate success?.
-
#users ⇒ Object
An array of of User-specific tokens and their Location at all levels the Client can see and larger.
Constructor Details
#initialize(doc) ⇒ Response
Parses the XML response from FireEagle
5 6 7 8 9 |
# File 'lib/fireeagle/response.rb', line 5 def initialize(doc) doc = Hpricot(doc) unless doc.is_a?(Hpricot::Doc || Hpricot::Elem) @doc = doc raise FireEagle::FireEagleException, @doc.at("/rsp/err").attributes["msg"] if !success? end |
Instance Method Details
#locations ⇒ Object
A Location array.
24 25 26 27 28 |
# File 'lib/fireeagle/response.rb', line 24 def locations @locations ||= @doc.search("/rsp/locations/location").map do |location| FireEagle::Location.new(location.to_s) end end |
#success? ⇒ Boolean
does the response indicate success?
12 13 14 |
# File 'lib/fireeagle/response.rb', line 12 def success? @doc.at("/rsp").attributes["stat"] == "ok" rescue false end |