class Blather::Stanza::Iq::Vcard

# Vcard Stanza

[XEP-0054 vcard-temp](xmpp.org/extensions/xep-0054.html)

This is a base class for any vcard based Iq stanzas. It provides a base set of methods for working with vcard stanzas

@example Retrieving One's vCard

iq = Blather::Stanza::Iq::Vcard.new :get
client.write_with_handler iq do |response|
  puts response.vcard
end

@example Updating One's vCard

iq = Blather::Stanza::Iq::Vcard.new :set
iq.vcard['NICKNAME'] = 'Romeo'
client.write_with_handler iq do |response|
  puts response
end

@example Viewing Another User's vCard

iq = Blather::Stanza::Iq::Vcard.new :get, 'mercutio@example.org'
client.write_with_handler iq do |response|
  puts response.vcard
end

@handler :vcard

Public Class Methods

new(type = nil, to = nil, id = nil) click to toggle source

Overrides the parent method to ensure a vcard node is created

@see Blather::Stanza::Iq.new

Calls superclass method Blather::Stanza::Iq::new
# File lib/blather/stanza/iq/vcard.rb, line 39
def self.new(type = nil, to = nil, id = nil)
  node = super
  node.vcard
  node
end

Public Instance Methods

inherit(node) click to toggle source

Overrides the parent method to ensure the current vcard node is destroyed

@see Blather::Stanza::Iq#inherit

Calls superclass method
# File lib/blather/stanza/iq/vcard.rb, line 48
def inherit(node)
  vcard.remove
  super
  self
end
vcard() click to toggle source

Find or create vcard node

@return [Vcard::Vcard]

# File lib/blather/stanza/iq/vcard.rb, line 57
def vcard
  Vcard.find_or_create self
end
vcard=(info) click to toggle source

Replaces vcard node

@param [Vcard::Vcard, XML::Node] info the stanza's new vcard node

@return [Vcard::Vcard]

# File lib/blather/stanza/iq/vcard.rb, line 66
def vcard=(info)
  vcard.remove
  self << info
  Vcard.find_or_create self
end