Class Jabber::Vcard::IqVcard
In: lib/xmpp4r/vcard/iq/vcard.rb
Parent: REXML::Element
XMLStanza Message Presence Iq REXML::Element X IqQuery Error StreamHost IqSiFileRange IqSiFile StreamHostUsed IqSi XRosterItem RosterItem IqFeature XMUCUserItem XMUCUserInvite Feature Identity Item XDataField XDataReported XDataTitle XDataInstructions IqVcard Singleton IdGenerator Connection Client Component Comparable JID RuntimeError ErrorException AuthenticationFailure SOCKS5Error Stream SOCKS5Bytestreams SOCKS5BytestreamsTarget SOCKS5BytestreamsInitiator SOCKS5BytestreamsServerStreamHost TCPSocket SOCKS5Socket IqQuery IqQueryBytestreams IqQueryVersion IqQueryRoster IqQueryDiscoItems IqQueryDiscoInfo IBB IBBTarget IBBInitiator Responder SimpleResponder X XRoster XMUCUser XMUC XDelay XData MUCClient SimpleMUCClient Base DigestMD5 Plain FileSource StreamParser SOCKS5BytestreamsPeer SOCKS5BytestreamsServer IBBQueueItem Helper MUCBrowser Helper Helper lib/xmpp4r/authenticationfailure.rb lib/xmpp4r/idgenerator.rb lib/xmpp4r/connection.rb lib/xmpp4r/iq.rb lib/xmpp4r/jid.rb lib/xmpp4r/xmlstanza.rb lib/xmpp4r/errorexception.rb lib/xmpp4r/stream.rb lib/xmpp4r/client.rb lib/xmpp4r/streamparser.rb lib/xmpp4r/x.rb lib/xmpp4r/error.rb lib/xmpp4r/component.rb lib/xmpp4r/query.rb lib/xmpp4r/message.rb lib/xmpp4r/presence.rb lib/xmpp4r/bytestreams/helper/ibb/initiator.rb lib/xmpp4r/bytestreams/iq/si.rb lib/xmpp4r/bytestreams/iq/bytestreams.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb lib/xmpp4r/bytestreams/helper/ibb/base.rb lib/xmpp4r/bytestreams/helper/ibb/target.rb Bytestreams lib/xmpp4r/version/iq/version.rb lib/xmpp4r/version/helper/responder.rb lib/xmpp4r/version/helper/simpleresponder.rb Version lib/xmpp4r/roster/helper/roster.rb lib/xmpp4r/roster/iq/roster.rb lib/xmpp4r/roster/x/roster.rb Roster lib/xmpp4r/feature_negotiation/iq/feature.rb FeatureNegotiation lib/xmpp4r/muc/x/muc.rb lib/xmpp4r/muc/helper/mucclient.rb lib/xmpp4r/muc/x/mucuseritem.rb lib/xmpp4r/muc/helper/mucbrowser.rb lib/xmpp4r/muc/x/mucuserinvite.rb lib/xmpp4r/muc/helper/simplemucclient.rb MUC lib/xmpp4r/sasl.rb SASL lib/xmpp4r/delay/x/delay.rb Delay lib/xmpp4r/bytestreams/helper/filetransfer.rb TransferSource FileTransfer lib/xmpp4r/discovery/iq/discoinfo.rb lib/xmpp4r/discovery/iq/discoitems.rb Discovery lib/xmpp4r/dataforms/x/data.rb Dataforms lib/xmpp4r/vcard/helper/vcard.rb lib/xmpp4r/vcard/iq/vcard.rb Vcard Jabber Module: Jabber

vCard container for User Information (can be specified by users themselves, mostly kept on servers) (JEP 0054)

Methods

[]   []=   fields   import   new  

Public Class methods

element:[REXML::Element] to import
result:[IqVcard] with all attributes and children copied from element

[Source]

    # File lib/xmpp4r/vcard/iq/vcard.rb, line 31
31:       def IqVcard.import(element)
32:         IqVcard::new.import(element)
33:       end

Initialize a <vCard/> element

fields:[Hash] Initialize with keys as XPath element names and values for element texts

[Source]

    # File lib/xmpp4r/vcard/iq/vcard.rb, line 17
17:       def initialize(fields=nil)
18:         super("vCard")
19:         add_namespace('vcard-temp')
20: 
21:         unless fields.nil?
22:           fields.each { |name,value|
23:             self[name] = value
24:           }
25:         end
26:       end

Public Instance methods

Get an elements/fields text

vCards have too much possible children, so ask for them here and extract the result with iqvcard.element(’…’).text

name:[String] XPath

[Source]

    # File lib/xmpp4r/vcard/iq/vcard.rb, line 41
41:       def [](name)
42:         text = nil
43:         each_element(name) { |child| text = child.text }
44:         text
45:       end

Set an elements/fields text

name:[String] XPath
text:[String] Value

[Source]

    # File lib/xmpp4r/vcard/iq/vcard.rb, line 51
51:       def []=(name, text)
52:         xe = self
53:         name.split(/\//).each do |elementname|
54:           # Does the children already exist?
55:           newxe = nil
56:           xe.each_element(elementname) { |child| newxe = child }
57: 
58:           if newxe.nil?
59:             # Create a new
60:             xe = xe.add_element(elementname)
61:           else
62:             # Or take existing
63:             xe = newxe
64:           end
65:         end
66:         xe.text = text
67:       end

Get vCard field names

Example:

 ["NICKNAME", "BDAY", "ORG/ORGUNIT", "PHOTO/TYPE", "PHOTO/BINVAL"]
result:[Array] of [String]

[Source]

    # File lib/xmpp4r/vcard/iq/vcard.rb, line 76
76:       def fields
77:         element_names(self).uniq
78:       end

[Validate]