Exception: Vines::StreamError

Inherits:
XmppError
  • Object
show all
Defined in:
lib/vines/error.rb

Constant Summary collapse

NAMESPACE =
'urn:ietf:params:xml:ns:xmpp-streams'.freeze

Instance Method Summary collapse

Methods inherited from XmppError

#element_name

Constructor Details

#initialize(text = nil) ⇒ StreamError

Returns a new instance of StreamError.



40
41
42
# File 'lib/vines/error.rb', line 40

def initialize(text=nil)
  @text = text
end

Instance Method Details

#to_xmlObject



44
45
46
47
48
49
50
51
52
# File 'lib/vines/error.rb', line 44

def to_xml
  doc = Document.new
  doc.create_element('stream:error') do |el|
    el << doc.create_element(element_name, 'xmlns' => NAMESPACE)
    if @text
      el << doc.create_element('text', @text, 'xmlns' => NAMESPACE, 'xml:lang' => 'en')
    end
  end.to_xml(:indent => 0).gsub(/\n/, '')
end