class Blather::Stanza::PubSub::Create

# PubSub Create Stanza

[XEP-0060 Section 8.1 - Create a Node](xmpp.org/extensions/xep-0060.html#owner-create)

@handler :pubsub_create

Public Class Methods

new(type = :set, host = nil, node = nil) click to toggle source

Create a new Create Stanza

@param [<Blather::Stanza::Iq::VALID_TYPES>] type the node type @param [String, nil] host the host to send the request to @param [String, nil] node the name of the node to create

Calls superclass method Blather::Stanza::PubSub::new
# File lib/blather/stanza/pubsub/create.rb, line 18
def self.new(type = :set, host = nil, node = nil)
  new_node = super(type, host)
  new_node.create_node
  new_node.configure_node
  new_node.node = node
  new_node
end

Public Instance Methods

configure_node() click to toggle source

Get or create the actual configure node on the stanza

@return [Blather::XMPPNode]

# File lib/blather/stanza/pubsub/create.rb, line 54
def configure_node
  unless configure_node = pubsub.find_first('ns:configure', :ns => self.class.registered_ns)
    self.pubsub << (configure_node = XMPPNode.new('configure', self.document))
    configure_node.namespace = self.pubsub.namespace
  end
  configure_node
end
create_node() click to toggle source

Get or create the actual create node on the stanza

@return [Blather::XMPPNode]

# File lib/blather/stanza/pubsub/create.rb, line 43
def create_node
  unless create_node = pubsub.find_first('ns:create', :ns => self.class.registered_ns)
    self.pubsub << (create_node = XMPPNode.new('create', self.document))
    create_node.namespace = self.pubsub.namespace
  end
  create_node
end
node() click to toggle source

Get the name of the node to create

@return [String, nil]

# File lib/blather/stanza/pubsub/create.rb, line 29
def node
  create_node[:node]
end
node=(node) click to toggle source

Set the name of the node to create

@param [String, nil] node

# File lib/blather/stanza/pubsub/create.rb, line 36
def node=(node)
  create_node[:node] = node
end