Class: FireEagle::Location
- Inherits:
-
Object
- Object
- FireEagle::Location
- Defined in:
- lib/fireeagle/location.rb
Instance Method Summary collapse
-
#best_guess? ⇒ Boolean
Is this Location FireEagle’s best guess?.
-
#geom ⇒ Object
(also: #geo)
The GeoRuby representation of this location.
-
#initialize(doc) ⇒ Location
constructor
Initialize a Location from an XML response.
- #label ⇒ Object
-
#level ⇒ Object
Level of granularity for this Location.
-
#level_name ⇒ Object
Name of the level of granularity for this Location.
-
#located_at ⇒ Object
The Time at which the User last updated in this Location.
-
#lower_corner ⇒ Object
The coordinates of the lower corner of a bounding box surrounding this Location.
-
#name ⇒ Object
(also: #to_s)
Human Name for this Location.
-
#place_id ⇒ Object
Unique identifier for this place.
-
#woeid ⇒ Object
Numeric unique identifier for this place.
Constructor Details
#initialize(doc) ⇒ Location
Initialize a Location from an XML response
6 7 8 9 |
# File 'lib/fireeagle/location.rb', line 6 def initialize(doc) doc = Hpricot(doc) unless doc.is_a?(Hpricot::Doc || Hpricot::Elem) @doc = doc end |
Instance Method Details
#best_guess? ⇒ Boolean
Is this Location FireEagle’s best guess?
65 66 67 |
# File 'lib/fireeagle/location.rb', line 65 def best_guess? @best_guess ||= @doc.at("/location").attributes["best-guess"] == "true" rescue false end |
#geom ⇒ Object Also known as: geo
The GeoRuby representation of this location
53 54 55 56 57 58 59 60 61 |
# File 'lib/fireeagle/location.rb', line 53 def geom if @doc.at("/location//georss:box") @geo ||= GeoRuby::SimpleFeatures::Geometry.from_georss(@doc.at("/location//georss:box").to_s) elsif @doc.at("/location//georss:point") @geo ||= GeoRuby::SimpleFeatures::Geometry.from_georss(@doc.at("/location//georss:point").to_s) else return nil end end |
#label ⇒ Object
11 12 13 |
# File 'lib/fireeagle/location.rb', line 11 def label @label ||= @doc.at("/location/label").innerText rescue nil end |
#level ⇒ Object
Level of granularity for this Location
16 17 18 |
# File 'lib/fireeagle/location.rb', line 16 def level @level ||= @doc.at("/location/level").innerText.to_i rescue nil end |
#level_name ⇒ Object
Name of the level of granularity for this Location
21 22 23 |
# File 'lib/fireeagle/location.rb', line 21 def level_name @level_name ||= @doc.at("/location/level-name").innerText rescue nil end |
#located_at ⇒ Object
The Time at which the User last updated in this Location
42 43 44 |
# File 'lib/fireeagle/location.rb', line 42 def located_at @located_at ||= Time.parse(@doc.at("/location/located-at").innerText) rescue nil end |
#lower_corner ⇒ Object
The coordinates of the lower corner of a bounding box surrounding this Location
47 48 49 50 |
# File 'lib/fireeagle/location.rb', line 47 def lower_corner @georss ||= @doc.at("/location//georss:box").innerText.split.map{ |l| l.to_f } rescue nil @lower_corner ||= @georss[0..1] rescue nil end |
#name ⇒ Object Also known as: to_s
Human Name for this Location
26 27 28 |
# File 'lib/fireeagle/location.rb', line 26 def name @name ||= @doc.at("/location/name").innerText rescue nil end |
#place_id ⇒ Object
Unique identifier for this place. Pro-tip: This is the same place_id used by Flickr.
32 33 34 |
# File 'lib/fireeagle/location.rb', line 32 def place_id @place_id ||= @doc.at("/location/place-id").innerText rescue nil end |
#woeid ⇒ Object
Numeric unique identifier for this place.
37 38 39 |
# File 'lib/fireeagle/location.rb', line 37 def woeid @woeid ||= @doc.at("/location/woeid").innerText rescue nil end |