Class Jabber::Dataforms::XData
In: lib/xmpp4r/dataforms/x/data.rb
Parent: X

Data Forms (JEP-0004) implementation

Methods

field   fields   instructions   instructions=   new   title   title=   type   type=  

Public Class methods

[Source]

    # File lib/xmpp4r/dataforms/x/data.rb, line 15
15:       def initialize(type=nil)
16:         super()
17:         self.type = type
18:       end

Public Instance methods

Search a field by it‘s var-name

var:[String]
result:[XDataField] or [nil]

[Source]

    # File lib/xmpp4r/dataforms/x/data.rb, line 24
24:       def field(var)
25:         each_element { |xe|
26:           return xe if xe.kind_of?(XDataField) and xe.var == var
27:         }
28:         nil
29:       end

[Source]

    # File lib/xmpp4r/dataforms/x/data.rb, line 31
31:       def fields
32:         fields = []
33:         each_element do |xe|
34:           if xe.kind_of?(XDataField) and xe.type != :hidden and xe.type != :fixed
35:             fields << xe
36:           end
37:         end
38:         fields
39:       end

Get the Data Form instructions

return:[Array] of [XDataInstructions] or nil

[Source]

    # File lib/xmpp4r/dataforms/x/data.rb, line 88
88:       def instructions
89:         fields = []
90:         each_element('instructions') do |xe|
91:           fields << xe
92:         end
93:         fields        
94:       end

Add Data Form instructions

i:[String]

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 99
 99:       def instructions=(i)
100:         add(XDataInstructions.new(i))
101:       end

Get the Data Form title

return:[XDataTitle] or nil

[Source]

    # File lib/xmpp4r/dataforms/x/data.rb, line 73
73:       def title
74:         first_element('title')
75:       end

Set the Data Form title

title:[String]

[Source]

    # File lib/xmpp4r/dataforms/x/data.rb, line 80
80:       def title=(title)
81:         delete_elements('title')
82:         add_element(XDataTitle.new(title))
83:       end

Type of this Data Form

result:* :cancel
  • :form
  • :result
  • :submit
  • nil

[Source]

    # File lib/xmpp4r/dataforms/x/data.rb, line 48
48:       def type
49:         case attributes['type']
50:           when 'cancel' then :cancel
51:           when 'form' then :form
52:           when 'result' then :result
53:           when 'submit' then :submit
54:           else nil
55:         end
56:       end

Set the type (see type)

[Source]

    # File lib/xmpp4r/dataforms/x/data.rb, line 60
60:       def type=(t)
61:         case t
62:           when :cancel then attributes['type'] = 'cancel'
63:           when :form then attributes['type'] = 'form'
64:           when :result then attributes['type'] = 'result'
65:           when :submit then attributes['type'] = 'submit'
66:           else attributes['type'] = nil
67:         end
68:       end

[Validate]