Class: Babylon::Base::Stanza
- Inherits:
-
Object
- Object
- Babylon::Base::Stanza
- Includes:
- SAXMachine
- Defined in:
- lib/babylon/base/stanza.rb
Overview
Class used to Parse a Stanza on the XMPP stream. You should have a Stanza subsclass for each of your controller actions, as they allow you to define which stanzas and which information is passed to yoru controllers.
You can define your own macthing pretty easily with the element and elements methods, as explained in the SaxMachine Documentation: github.com/pauldix/sax-machine/tree/master if your stanza is a message stanza, you can match the following for example: element :message, :value => :to, :as => :to element :message, :value => :from, :as => :from element :message, :value => :id, :as => :stanza_id element :message, :value => :type, :as => :stanza_type element :message, :value => :“xml:lang”, :as => :lang
Instance Method Summary collapse
-
#initialize(xml = nil) ⇒ Stanza
constructor
A new instance of Stanza.
Constructor Details
#initialize(xml = nil) ⇒ Stanza
Returns a new instance of Stanza.
18 19 20 |
# File 'lib/babylon/base/stanza.rb', line 18 def initialize(xml = nil) parse(xml.to_s) end |