lib/blather/stanza/x.rb in blather-0.4.16 vs lib/blather/stanza/x.rb in blather-0.5.0

- old
+ new

@@ -8,10 +8,11 @@ # # @handler :x class X < XMPPNode register :x, 'jabber:x:data' + # @private VALID_TYPES = [:cancel, :form, :result, :submit].freeze # Create a new X node # @param [:cancel, :form, :result, :submit, nil] type the x:form type # @param [Array<Array, X::Field>, nil] fields a list of fields. @@ -31,10 +32,14 @@ new_node.fields = fields end new_node end + # Find the X node on the parent or create a new one + # + # @param [Blather::Stanza] parent the parent node to search under + # @return [Blather::Stanza::X] def self.find_or_create(parent) if found_x = parent.find_first('//ns:x', :ns => self.registered_ns) x = self.new found_x found_x.remove else @@ -147,12 +152,14 @@ t.namespace = self.namespace t << title end end + # Field stanza fragment class Field < XMPPNode register :field, 'jabber:x:data' + # @private VALID_TYPES = [:boolean, :fixed, :hidden, :"jid-multi", :"jid-single", :"list-multi", :"list-single", :"text-multi", :"text-private", :"text-single"].freeze # Create a new X Field # @overload new(node) # Imports the XML::Node to create a Field object @@ -333,9 +340,10 @@ # @return [true, false] def eql?(o, *fields) super o, *(fields + [:type, :var, :label, :desc, :required?, :value]) end + # Option stanza fragment class Option < XMPPNode register :option, 'jabber:x:data' # Create a new X Field Option # @overload new(node) # Imports the XML::Node to create a Field option object