Sha256: 3e3b8a0e29ad311a3bbf1cc936c3a9ecd75b98a6ec646d14dfd026fdd1c91cde
Contents?: true
Size: 1.5 KB
Versions: 3
Compression:
Stored size: 1.5 KB
Contents
class FireEagle class User #Parses the XML response from FireEagle. def initialize(doc) doc = Hpricot(doc) unless doc.is_a?(Hpricot::Doc || Hpricot::Elem) @doc = doc end #The User-specific token for this Client. def token @token ||= @doc.at("/user").attributes["token"] rescue nil end #The time at which this user was last located def located_at @located_at ||= Time.parse(@doc.at("/user").attributes["located-at"]) rescue nil end #FireEagle's "best guess" form this User's Location. This best guess is derived as the most accurate #level of the hierarchy with a timestamp in the last half an hour <b>or</b> as the most accurate #level of the hierarchy with the most recent timestamp. def best_guess @best_guess ||= locations.select { |location| location.best_guess? }.first rescue nil end #An Array containing all Location granularity that the Client has been allowed to #see for the User. The Location elements returned are arranged in hierarchy order consisting of: #Country, State, County, Large Cities, Neighbourhoods/Local Area, Postal Code and exact location. #The Application should therefore be prepared to receive a response that may consist of (1) only #country, or (2) country & state or (3) country, state & county and so forth. def locations @locations ||= @doc.search("/user/location-hierarchy/location").map do |location| FireEagle::Location.new(location.to_s) end end end end
Version data entries
3 entries across 3 versions & 3 rubygems
Version | Path |
---|---|
jnewland-fireeagle-0.8.0.0 | lib/fireeagle/user.rb |
pezra-fireeagle-0.9.0.1 | lib/fireeagle/user.rb |
fireeagle-0.8.0.0 | lib/fireeagle/user.rb |