class Blather::Stanza::DiscoItems::Item

An individual Disco Item

Public Class Methods

new(jid, node = nil, name = nil) click to toggle source

Create a new Blather::Stanza::DiscoItems::Item

@overload new(node)

Create a new Item by inheriting an existing node
@param [XML::Node] node an XML::Node to inherit from

@overload new(opts)

Create a new Item through a hash of options
@param [Hash] opts a hash options
@option opts [Blather::JID, String] :jid the JID to attach to the item
@option opts [#to_s] :node the node the item is attached to
@option opts [#to_S] :name the name of the Item

@overload new(jid, node = nil, name = nil)

Create a new Item
@param [Blather::JID, String] jid the JID to attach to the item
@param [#to_s] node the node the item is attached to
@param [#to_s] name the name of the Item
Calls superclass method
# File lib/blather/stanza/disco/disco_items.rb, line 64
def self.new(jid, node = nil, name = nil)
  return jid if jid.class == self

  new_node = super :item

  case jid
  when Nokogiri::XML::Node
    new_node.inherit jid
  when Hash
    new_node.jid = jid[:jid]
    new_node.node = jid[:node]
    new_node.name = jid[:name]
  else
    new_node.jid = jid
    new_node.node = node
    new_node.name = name
  end
  new_node
end

Public Instance Methods

eql?(o, *fields) click to toggle source

Compare two DiscoItems::Item objects by name, type and category @param [DiscoItems::Item] o the Identity object to compare against @return [true, false]

Calls superclass method
# File lib/blather/stanza/disco/disco_items.rb, line 129
def eql?(o, *fields)
  super o, *(fields + [:jid, :node, :name])
end
jid() click to toggle source

Get the JID attached to the node

@return [Blather::JID, nil]

# File lib/blather/stanza/disco/disco_items.rb, line 87
def jid
  (j = self[:jid]) ? JID.new(j) : nil
end
jid=(jid) click to toggle source

Set the JID of the node

@param [Blather::JID, String, nil] jid the new JID

# File lib/blather/stanza/disco/disco_items.rb, line 94
def jid=(jid)
  write_attr :jid, jid
end
name() click to toggle source

Get the Item name

@return [String, nil]

# File lib/blather/stanza/disco/disco_items.rb, line 115
def name
  read_attr :name
end
name=(name) click to toggle source

Set the Item name

@param [#to_s] name the Item name

# File lib/blather/stanza/disco/disco_items.rb, line 122
def name=(name)
  write_attr :name, name
end
node() click to toggle source

Get the name of the node

@return [String, nil]

# File lib/blather/stanza/disco/disco_items.rb, line 101
def node
  read_attr :node
end
node=(node) click to toggle source

Set the name of the node

@param [String, nil] node the new node name

# File lib/blather/stanza/disco/disco_items.rb, line 108
def node=(node)
  write_attr :node, node
end