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.
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 |
# 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
Get the description attribute of this location.
# File lib/xmpp4r/location/location.rb, line 102 102: def description 103: first_element('description').text if first_element('description') 104: end
Get the postalcode attribute of this location.
# 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.
# File lib/xmpp4r/location/location.rb, line 54 54: def published? 55: (elements.size > 0) 56: end