| Class | Jabber::Dataforms::XData |
| In: |
lib/xmpp4r/dataforms/x/data.rb
|
| Parent: | X |
Data Forms (JEP-0004) implementation
# File lib/xmpp4r/dataforms/x/data.rb, line 15
15: def initialize(type=nil)
16: super()
17: self.type = type
18: end
Search a field by it‘s var-name
| var: | [String] |
| result: | [XDataField] or [nil] |
# 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
# File lib/xmpp4r/dataforms/x/data.rb, line 31
31: def fields(including_hidden=false)
32: fields = []
33: each_element do |xe|
34: if xe.kind_of?(XDataField) and (including_hidden or
35: (xe.type != :hidden and xe.type != :fixed))
36: fields << xe
37: end
38: end
39: fields
40: end
Get the Data Form instructions
| return: | [Array] of [XDataInstructions] or nil |
# File lib/xmpp4r/dataforms/x/data.rb, line 89
89: def instructions
90: fields = []
91: each_element('instructions') do |xe|
92: fields << xe
93: end
94: fields
95: end
Add Data Form instructions
| i: | [String] |
# File lib/xmpp4r/dataforms/x/data.rb, line 100
100: def instructions=(i)
101: add(XDataInstructions.new(i))
102: end
Get the Data Form title
| return: | [XDataTitle] or nil |
# File lib/xmpp4r/dataforms/x/data.rb, line 74
74: def title
75: first_element('title')
76: end
Type of this Data Form
| result: | * :cancel
|
# File lib/xmpp4r/dataforms/x/data.rb, line 49
49: def type
50: case attributes['type']
51: when 'cancel' then :cancel
52: when 'form' then :form
53: when 'result' then :result
54: when 'submit' then :submit
55: else nil
56: end
57: end
# File lib/xmpp4r/dataforms/x/data.rb, line 61
61: def type=(t)
62: case t
63: when :cancel then attributes['type'] = 'cancel'
64: when :form then attributes['type'] = 'form'
65: when :result then attributes['type'] = 'result'
66: when :submit then attributes['type'] = 'submit'
67: else attributes['type'] = nil
68: end
69: end