class Blather::Stanza::DiscoInfo::Identity

DiscoInfo::Identity

Public Class Methods

new(name, type = nil, category = nil, xml_lang = nil) click to toggle source

Create a new DiscoInfo::Identity @overload new(node)

Imports the XML::Node to create a Identity object
@param [XML::Node] node the node object to import

@overload new(opts = {})

Creates a new Identity using a hash of options
@param [Hash] opts a hash of options
@option opts [String] :name the name of the identity
@option opts [String] :type the type of the identity
@option opts [String] :category the category of the identity

@overload new(name, type = nil, category = nil)

Create a new Identity by name
@param [String] name the name of the Identity
@param [String, nil] type the type of the Identity
@param [String, nil] category the category of the Identity
Calls superclass method
# File lib/blather/stanza/disco/disco_info.rb, line 86
def self.new(name, type = nil, category = nil, xml_lang = nil)
  return name if name.class == self

  new_node = super :identity

  case name
  when Nokogiri::XML::Node
    new_node.inherit name
  when Hash
    new_node.name = name[:name]
    new_node.type = name[:type]
    new_node.category = name[:category]
    new_node.xml_lang = name[:xml_lang]
  else
    new_node.name = name
    new_node.type = type
    new_node.category = category
    new_node.xml_lang = xml_lang
  end
  new_node
end

Public Instance Methods

category() click to toggle source

The Identity's category @return [Symbol, nil]

# File lib/blather/stanza/disco/disco_info.rb, line 110
def category
  read_attr :category, :to_sym
end
category=(category) click to toggle source

Set the Identity's category @param [String, Symbol] category the new category

# File lib/blather/stanza/disco/disco_info.rb, line 116
def category=(category)
  write_attr :category, category
end
eql?(o, *fields) click to toggle source

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

Calls superclass method
# File lib/blather/stanza/disco/disco_info.rb, line 159
def eql?(o, *fields)
  super o, *(fields + [:name, :type, :category, :xml_lang])
end
name() click to toggle source

The Identity's name @return [String]

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

Set the Identity's name @param [String] name the new name for the identity

# File lib/blather/stanza/disco/disco_info.rb, line 140
def name=(name)
  write_attr :name, name
end
type() click to toggle source

The Identity's type @return [Symbol, nil]

# File lib/blather/stanza/disco/disco_info.rb, line 122
def type
  read_attr :type, :to_sym
end
type=(type) click to toggle source

Set the Identity's type @param [String, Symbol] type the new category

# File lib/blather/stanza/disco/disco_info.rb, line 128
def type=(type)
  write_attr :type, type
end
xml_lang() click to toggle source

The Identity's xml_lang @return [String]

# File lib/blather/stanza/disco/disco_info.rb, line 146
def xml_lang
  read_attr "xml:lang"
end
xml_lang=(xml_lang) click to toggle source

Set the Identity's name @param [String] name the new name for the identity

# File lib/blather/stanza/disco/disco_info.rb, line 152
def xml_lang=(xml_lang)
  write_attr "xml:lang", xml_lang
end