Class: Jabber::UserLocation::Location
- Inherits:
-
XMPPElement
- Object
- REXML::Element
- XMPPElement
- Jabber::UserLocation::Location
- Defined in:
- lib/xmpp4r/location/location.rb
Overview
The
See http://xmpp.org/extensions/xep-0080.html - this element
encapsulates data about a user's current location. These are
expressed as child elements such as
If the element has no children then it indicates that the user has stopped publishing their location.
Instance Method Summary collapse
-
#accuracy ⇒ Object
Get the accuracy attribute of this location.
-
#alt ⇒ Object
Get the alt attribute of this location.
-
#area ⇒ Object
Get the area attribute of this location.
-
#bearing ⇒ Object
Get the bearing attribute of this location.
-
#building ⇒ Object
Get the building attribute of this location.
-
#country ⇒ Object
Get the country attribute of this location.
-
#datum ⇒ Object
Get the datum attribute of this location.
-
#description ⇒ Object
Get the description attribute of this location.
-
#floor ⇒ Object
Get the floor attribute of this location.
-
#initialize(attributes = {}) ⇒ Location
constructor
Construct a new
element. -
#lat ⇒ Object
Get the lat attribute of this location.
-
#locality ⇒ Object
Get the locality attribute of this location.
-
#lon ⇒ Object
Get the lon attribute of this location.
-
#postalcode ⇒ Object
Get the postalcode attribute of this location.
-
#published? ⇒ Boolean
Returns true if a location is currently being published, otherwise false.
-
#region ⇒ Object
Get the region attribute of this location.
-
#room ⇒ Object
Get the room attribute of this location.
-
#speed ⇒ Object
Get the speed attribute of this location.
-
#street ⇒ Object
Get the street attribute of this location.
-
#text ⇒ Object
Get the text attribute of this location.
-
#timestamp ⇒ Object
Get the timestamp attribute of this location.
-
#uri ⇒ Object
Get the uri attribute of this location.
Methods inherited from XMPPElement
class_for_name_xmlns, #clone, force_xmlns, force_xmlns?, import, name_xmlns, name_xmlns_for_class, #parent=, #set_xml_lang, #typed_add, #xml_lang, #xml_lang=
Methods inherited from REXML::Element
#==, #delete_elements, #each_elements, #first_element, #first_element_content, #first_element_text, #import, import, #replace_element_content, #replace_element_text, #typed_add
Constructor Details
#initialize(attributes = {}) ⇒ Location
Construct a new
Supply no arguments to make an empty element to indicate that location is no longer being published.
- attributes
[Hash] location attributes
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/xmpp4r/location/location.rb', line 37 def initialize(attributes = {}) super() # validate attributes attributes = attributes.select do |k,v| ALLOWABLE_ATTRIBUTES.include?(k) && !v.nil? end attributes.each do |k,v| v = x.xmlschema if v.is_a?(Time) add_element(REXML::Element.new(k)).text = v.to_s end end |
Instance Method Details
#accuracy ⇒ Object
Get the accuracy attribute of this location.
60 61 62 |
# File 'lib/xmpp4r/location/location.rb', line 60 def accuracy first_element('accuracy').text if first_element('accuracy') end |
#alt ⇒ Object
Get the alt attribute of this location.
66 67 68 |
# File 'lib/xmpp4r/location/location.rb', line 66 def alt first_element('alt').text if first_element('alt') end |
#area ⇒ Object
Get the area attribute of this location.
72 73 74 |
# File 'lib/xmpp4r/location/location.rb', line 72 def area first_element('area').text if first_element('area') end |
#bearing ⇒ Object
Get the bearing attribute of this location.
78 79 80 |
# File 'lib/xmpp4r/location/location.rb', line 78 def bearing first_element('bearing').text if first_element('bearing') end |
#building ⇒ Object
Get the building attribute of this location.
84 85 86 |
# File 'lib/xmpp4r/location/location.rb', line 84 def building first_element('building').text if first_element('building') end |
#country ⇒ Object
Get the country attribute of this location.
90 91 92 |
# File 'lib/xmpp4r/location/location.rb', line 90 def country first_element('country').text if first_element('country') end |
#datum ⇒ Object
Get the datum attribute of this location.
96 97 98 |
# File 'lib/xmpp4r/location/location.rb', line 96 def datum first_element('datum').text if first_element('datum') end |
#description ⇒ Object
Get the description attribute of this location.
102 103 104 |
# File 'lib/xmpp4r/location/location.rb', line 102 def description first_element('description').text if first_element('description') end |
#floor ⇒ Object
Get the floor attribute of this location.
108 109 110 |
# File 'lib/xmpp4r/location/location.rb', line 108 def floor first_element('floor').text if first_element('floor') end |
#lat ⇒ Object
Get the lat attribute of this location.
114 115 116 |
# File 'lib/xmpp4r/location/location.rb', line 114 def lat first_element('lat').text if first_element('lat') end |
#locality ⇒ Object
Get the locality attribute of this location.
120 121 122 |
# File 'lib/xmpp4r/location/location.rb', line 120 def locality first_element('locality').text if first_element('locality') end |
#lon ⇒ Object
Get the lon attribute of this location.
126 127 128 |
# File 'lib/xmpp4r/location/location.rb', line 126 def lon first_element('lon').text if first_element('lon') end |
#postalcode ⇒ Object
Get the postalcode attribute of this location.
132 133 134 |
# File 'lib/xmpp4r/location/location.rb', line 132 def postalcode first_element('postalcode').text if first_element('postalcode') end |
#published? ⇒ Boolean
Returns true if a location is currently being published, otherwise false.
54 55 56 |
# File 'lib/xmpp4r/location/location.rb', line 54 def published? (elements.size > 0) end |
#region ⇒ Object
Get the region attribute of this location.
138 139 140 |
# File 'lib/xmpp4r/location/location.rb', line 138 def region first_element('region').text if first_element('region') end |
#room ⇒ Object
Get the room attribute of this location.
144 145 146 |
# File 'lib/xmpp4r/location/location.rb', line 144 def room first_element('room').text if first_element('room') end |
#speed ⇒ Object
Get the speed attribute of this location.
150 151 152 |
# File 'lib/xmpp4r/location/location.rb', line 150 def speed first_element('speed').text if first_element('speed') end |
#street ⇒ Object
Get the street attribute of this location.
156 157 158 |
# File 'lib/xmpp4r/location/location.rb', line 156 def street first_element('street').text if first_element('street') end |
#text ⇒ Object
Get the text attribute of this location.
162 163 164 |
# File 'lib/xmpp4r/location/location.rb', line 162 def text first_element('text').text if first_element('text') end |
#timestamp ⇒ Object
Get the timestamp attribute of this location.
168 169 170 |
# File 'lib/xmpp4r/location/location.rb', line 168 def first_element('timestamp').text if first_element('timestamp') end |
#uri ⇒ Object
Get the uri attribute of this location.
174 175 176 |
# File 'lib/xmpp4r/location/location.rb', line 174 def uri first_element('uri').text if first_element('uri') end |