Class: Blather::Stanza::Message::MUCUser::InviteBase

Inherits:
XMPPNode
  • Object
show all
Defined in:
lib/blather/stanza/message/muc_user.rb

Direct Known Subclasses

Decline, Invite

Constant Summary

Constants inherited from XMPPNode

XMPPNode::BASE_NAMES

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from XMPPNode

class_from_registration, #decorate, decorator_modules, import, parse, register, #to_stanza

Class Method Details

.new(element_name, to = nil, from = nil, reason = nil, document = nil) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/blather/stanza/message/muc_user.rb', line 51

def self.new(element_name, to = nil, from = nil, reason = nil, document = nil)
  new_node = super element_name, document

  case to
  when self
    to.document ||= document
    return to
  when Nokogiri::XML::Node
    new_node.inherit to
  when Hash
    new_node.to = to[:to]
    new_node.from = to[:from]
    new_node.reason = to[:reason]
  else
    new_node.to = to
    new_node.from = from
    new_node.reason = reason
  end
  new_node
end

Instance Method Details

#fromObject



80
81
82
# File 'lib/blather/stanza/message/muc_user.rb', line 80

def from
  read_attr :from
end

#from=(val) ⇒ Object



84
85
86
# File 'lib/blather/stanza/message/muc_user.rb', line 84

def from=(val)
  write_attr :from, val
end

#reasonObject



88
89
90
# File 'lib/blather/stanza/message/muc_user.rb', line 88

def reason
  reason_node.content.strip
end

#reason=(val) ⇒ Object



92
93
94
# File 'lib/blather/stanza/message/muc_user.rb', line 92

def reason=(val)
  reason_node.content = val
end

#reason_nodeObject



96
97
98
99
100
101
# File 'lib/blather/stanza/message/muc_user.rb', line 96

def reason_node
  unless reason = find_first('ns:reason', :ns => MUCUser.registered_ns)
    self << (reason = XMPPNode.new('reason', self.document))
  end
  reason
end

#toObject



72
73
74
# File 'lib/blather/stanza/message/muc_user.rb', line 72

def to
  read_attr :to
end

#to=(val) ⇒ Object



76
77
78
# File 'lib/blather/stanza/message/muc_user.rb', line 76

def to=(val)
  write_attr :to, val
end