Sha256: a087e9b2366f17b19dd439d5bf102ec64935ea42780dd47988c1b4ca150439c4

Contents?: true

Size: 853 Bytes

Versions: 12

Compression:

Stored size: 853 Bytes

Contents

class FireEagle
  class Response

    #Parses the XML response from FireEagle
    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

    #does the response indicate success?
    def success?
      @doc.at("/rsp").attributes["stat"] == "ok" rescue false
    end

    #An array of of User-specific tokens and their Location at all levels the Client can see and larger.
    def users
      @users ||= @doc.search("/rsp//user").map do |user|
        FireEagle::User.new(user.to_s)
      end
    end

    #A Location array.
    def locations
      @locations ||= @doc.search("/rsp/locations/location").map do |location|
        FireEagle::Location.new(location.to_s)
      end
    end

  end
end

Version data entries

12 entries across 12 versions & 4 rubygems

Version Path
jnewland-fireeagle-0.7.1.0 lib/fireeagle/response.rb
jnewland-fireeagle-0.8.0.0 lib/fireeagle/response.rb
mojodna-fireeagle-0.7.0.0 lib/fireeagle/response.rb
mojodna-fireeagle-0.7.0.1 lib/fireeagle/response.rb
mojodna-fireeagle-0.7.0 lib/fireeagle/response.rb
pezra-fireeagle-0.9.0.1 lib/fireeagle/response.rb
fireeagle-0.6.2 lib/fireeagle/response.rb
fireeagle-0.7.1.0 lib/fireeagle/response.rb
fireeagle-0.6.3 lib/fireeagle/response.rb
fireeagle-0.6.1 lib/fireeagle/response.rb
fireeagle-0.6.0 lib/fireeagle/response.rb
fireeagle-0.8.0.0 lib/fireeagle/response.rb