Class Jabber::UserLocation::Location
In: lib/xmpp4r/location/location.rb
Parent: XMPPElement

The <geoloc> XMPP element, as defined in XEP-0080 User Location

See xmpp.org/extensions/xep-0080.html - this element encapsulates data about a user‘s current location. These are expressed as child elements such as <locality>, <lat>, etc. which are also managed by this class.

If the element has no children then it indicates that the user has stopped publishing their location.

Methods

accuracy   alt   area   bearing   building   country   datum   description   floor   lat   locality   lon   new   postalcode   published?   region   room   speed   street   text   timestamp   uri  

Public Class methods

Construct a new <location> element.

Supply no arguments to make an empty element to indicate that location is no longer being published.

attributes:[Hash] location attributes

[Source]

    # File lib/xmpp4r/location/location.rb, line 37
37:       def initialize(attributes = {})
38:         super()
39: 
40:         # validate attributes
41:         attributes = attributes.select do |k,v|
42:           ALLOWABLE_ATTRIBUTES.include?(k) && !v.nil?
43:         end
44: 
45:         attributes.each do |k,v|
46:           v = x.xmlschema if v.is_a?(Time)
47:           add_element(REXML::Element.new(k)).text = v.to_s
48:         end
49:       end

Public Instance methods

Get the accuracy attribute of this location.

[Source]

    # File lib/xmpp4r/location/location.rb, line 60
60:       def accuracy
61:         first_element('accuracy').text if first_element('accuracy')
62:       end

Get the alt attribute of this location.

[Source]

    # File lib/xmpp4r/location/location.rb, line 66
66:       def alt
67:         first_element('alt').text if first_element('alt')
68:       end

Get the area attribute of this location.

[Source]

    # File lib/xmpp4r/location/location.rb, line 72
72:       def area
73:         first_element('area').text if first_element('area')
74:       end

Get the bearing attribute of this location.

[Source]

    # File lib/xmpp4r/location/location.rb, line 78
78:       def bearing
79:         first_element('bearing').text if first_element('bearing')
80:       end

Get the building attribute of this location.

[Source]

    # File lib/xmpp4r/location/location.rb, line 84
84:       def building
85:         first_element('building').text if first_element('building')
86:       end

Get the country attribute of this location.

[Source]

    # File lib/xmpp4r/location/location.rb, line 90
90:       def country
91:         first_element('country').text if first_element('country')
92:       end

Get the datum attribute of this location.

[Source]

    # File lib/xmpp4r/location/location.rb, line 96
96:       def datum
97:         first_element('datum').text if first_element('datum')
98:       end

Get the description attribute of this location.

[Source]

     # File lib/xmpp4r/location/location.rb, line 102
102:       def description
103:         first_element('description').text if first_element('description')
104:       end

Get the floor attribute of this location.

[Source]

     # File lib/xmpp4r/location/location.rb, line 108
108:       def floor
109:         first_element('floor').text if first_element('floor')
110:       end

Get the lat attribute of this location.

[Source]

     # File lib/xmpp4r/location/location.rb, line 114
114:       def lat
115:         first_element('lat').text if first_element('lat')
116:       end

Get the locality attribute of this location.

[Source]

     # File lib/xmpp4r/location/location.rb, line 120
120:       def locality
121:         first_element('locality').text if first_element('locality')
122:       end

Get the lon attribute of this location.

[Source]

     # File lib/xmpp4r/location/location.rb, line 126
126:       def lon
127:         first_element('lon').text if first_element('lon')
128:       end

Get the postalcode attribute of this location.

[Source]

     # File lib/xmpp4r/location/location.rb, line 132
132:       def postalcode
133:         first_element('postalcode').text if first_element('postalcode')
134:       end

Returns true if a location is currently being published, otherwise false.

[Source]

    # File lib/xmpp4r/location/location.rb, line 54
54:       def published?
55:         (elements.size > 0)
56:       end

Get the region attribute of this location.

[Source]

     # File lib/xmpp4r/location/location.rb, line 138
138:       def region
139:         first_element('region').text if first_element('region')
140:       end

Get the room attribute of this location.

[Source]

     # File lib/xmpp4r/location/location.rb, line 144
144:       def room
145:         first_element('room').text if first_element('room')
146:       end

Get the speed attribute of this location.

[Source]

     # File lib/xmpp4r/location/location.rb, line 150
150:       def speed
151:         first_element('speed').text if first_element('speed')
152:       end

Get the street attribute of this location.

[Source]

     # File lib/xmpp4r/location/location.rb, line 156
156:       def street
157:         first_element('street').text if first_element('street')
158:       end

Get the text attribute of this location.

[Source]

     # File lib/xmpp4r/location/location.rb, line 162
162:       def text
163:         first_element('text').text if first_element('text')
164:       end

Get the timestamp attribute of this location.

[Source]

     # File lib/xmpp4r/location/location.rb, line 168
168:       def timestamp
169:         first_element('timestamp').text if first_element('timestamp')
170:       end

Get the uri attribute of this location.

[Source]

     # File lib/xmpp4r/location/location.rb, line 174
174:       def uri
175:         first_element('uri').text if first_element('uri')
176:       end

[Validate]