Class: FireEagle::Location

Inherits:
Object
  • Object
show all
Defined in:
lib/fireeagle/location.rb

Instance Method Summary collapse

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?

Returns:

  • (Boolean)


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

#geomObject 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

#labelObject



11
12
13
# File 'lib/fireeagle/location.rb', line 11

def label
  @label ||= @doc.at("/location/label").innerText rescue nil
end

#levelObject

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_nameObject

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_atObject

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_cornerObject

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

#nameObject 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_idObject

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

#woeidObject

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