Class: Jabber::Command::IqCommand

Inherits:
Iq show all
Defined in:
lib/xmpp4r/command/iq/command.rb

Overview

Class for handling ad-hoc commands (JEP 0050)

A command is uniquely identified by its node attribute.

Instance Method Summary collapse

Methods inherited from Iq

#command, new_authset, new_authset_digest, new_browseget, new_query, new_register, new_registerget, new_rosterget, new_rosterset, #pubsub, #query, #query=, #queryns, #set_type, #type, #type=, #vcard

Methods inherited from XMPPStanza

answer, #answer, #error, #from, #from=, #id, #id=, #normalize, #set_from, #set_id, #set_to, #set_type, #to, #to=, #type, #type=

Methods inherited from XMPPElement

class_for_name_xmlns, #clone, force_xmlns, force_xmlns?, import, name_xmlns, name_xmlns_for_class, #parent=, #set_xml_lang, #typed_add, #xml_lang, #xml_lang=

Methods inherited from REXML::Element

#==, #delete_elements, #each_elements, #first_element, #first_element_content, #first_element_text, #import, import, #replace_element_content, #replace_element_text, #typed_add

Constructor Details

#initialize(node = nil, action = nil) ⇒ IqCommand


15
16
17
18
19
# File 'lib/xmpp4r/command/iq/command.rb', line 15

def initialize(node=nil, action=nil)
  super()
  set_node(node)
  set_action(action)
end

Instance Method Details

#actionObject

Get the action of the Command stanza

The following Symbols are allowed:

  • :execute

  • :cancel

  • :prev

  • :next

  • :complete

return
Symbol

or nil


75
76
77
78
79
80
81
82
83
84
# File 'lib/xmpp4r/command/iq/command.rb', line 75

def action
  case attributes['action']
    when 'execute' then :execute
    when 'cancel' then :cancel
    when 'prev' then :prev
    when 'next' then :next
    when 'complete' then :complete
    else nil
  end
end

#action=(v) ⇒ Object

Set the action of the Command stanza (see IqCommand#action for details)

v
Symbol

or nil


89
90
91
92
93
94
95
96
97
98
# File 'lib/xmpp4r/command/iq/command.rb', line 89

def action=(v)
  attributes['action'] = case v
    when :execute then 'execute'
    when :cancel then 'cancel'
    when :prev then 'prev'
    when :next then 'next'
    when :complete then 'complete'
    else nil
  end
end

#actionsObject

Get the actions allowed

return
REXML::Element

or nil


148
149
150
# File 'lib/xmpp4r/command/iq/command.rb', line 148

def actions
  first_element('actions')
end

#nodeObject

Get the node of the Command stanza

result
String

or nil


24
25
26
# File 'lib/xmpp4r/command/iq/command.rb', line 24

def node
  attributes['node']
end

#node=(v) ⇒ Object

Set the node of the Command stanza

v
String

or nil


31
32
33
# File 'lib/xmpp4r/command/iq/command.rb', line 31

def node=(v)
  attributes['node'] = v
end

#sessionidObject

Get the sessionid of the Command stanza

result
String

or nil


46
47
48
# File 'lib/xmpp4r/command/iq/command.rb', line 46

def sessionid
  attributes['sessionid']
end

#sessionid=(v) ⇒ Object

Set the sessionid of the Command stanza

v
String

or nil


53
54
55
# File 'lib/xmpp4r/command/iq/command.rb', line 53

def sessionid=(v)
  attributes['sessionid'] = v
end

#set_action(v) ⇒ Object

Set the action of the Command stanza (chaining-friendly)

v
Symbol

or nil


103
104
105
106
# File 'lib/xmpp4r/command/iq/command.rb', line 103

def set_action(v)
  self.action = v
  self
end

#set_node(v) ⇒ Object

Set the node of the Command stanza (chaining-friendly)

v
String

or nil


38
39
40
41
# File 'lib/xmpp4r/command/iq/command.rb', line 38

def set_node(v)
  self.node = v
  self
end

#set_sessionid(v) ⇒ Object

Set the sessionid of the Command stanza (chaining-friendly)

v
String

or nil


60
61
62
63
# File 'lib/xmpp4r/command/iq/command.rb', line 60

def set_sessionid(v)
  self.sessionid = v
  self
end

#set_status(v) ⇒ Object

Set the status of the Command stanza (chaining-friendly)

v
Symbol

or nil


140
141
142
143
# File 'lib/xmpp4r/command/iq/command.rb', line 140

def set_status(v)
  self.status = v
  self
end

#statusObject

Get the status of the Command stanza

The following Symbols are allowed:

  • :executing

  • :completed

  • :canceled

return
Symbol

or nil


116
117
118
119
120
121
122
123
# File 'lib/xmpp4r/command/iq/command.rb', line 116

def status
  case attributes['status']
    when 'executing' then :executing
    when 'completed' then :completed
    when 'canceled' then :canceled
    else nil
  end
end

#status=(v) ⇒ Object

Set the status of the Command stanza (see IqCommand#status for details)

v
Symbol

or nil


128
129
130
131
132
133
134
135
# File 'lib/xmpp4r/command/iq/command.rb', line 128

def status=(v)
  attributes['status'] = case v
    when :executing then 'executing'
    when :completed then 'completed'
    when :canceled then 'canceled'
    else nil
  end
end