Data Forms (JEP-0004) implementation
# File lib/xmpp4r/dataforms/x/data.rb, line 15 def initialize(type=nil) super() self.type = type end
Search a field by it's var-name
or [nil]
# File lib/xmpp4r/dataforms/x/data.rb, line 24 def field(var) each_element { |xe| return xe if xe.kind_of?(XDataField) and xe.var == var } nil end
# File lib/xmpp4r/dataforms/x/data.rb, line 31 def fields(including_hidden=false) fields = [] each_element do |xe| if xe.kind_of?(XDataField) and (including_hidden or (xe.type != :hidden and xe.type != :fixed)) fields << xe end end fields end
Get the Data Form instructions
of [XDataInstructions] or nil
# File lib/xmpp4r/dataforms/x/data.rb, line 89 def instructions fields = [] each_element('instructions') do |xe| fields << xe end fields end
Add Data Form instructions
# File lib/xmpp4r/dataforms/x/data.rb, line 100 def instructions=(i) add(XDataInstructions.new(i)) end
Get the Data Form title
or nil
# File lib/xmpp4r/dataforms/x/data.rb, line 74 def title first_element('title') end
Set the Data Form title
# File lib/xmpp4r/dataforms/x/data.rb, line 81 def title=(title) delete_elements('title') add_element(XDataTitle.new(title)) end
Type of this Data Form
:cancel
:form
:result
:submit
nil
# File lib/xmpp4r/dataforms/x/data.rb, line 49 def type case attributes['type'] when 'cancel' then :cancel when 'form' then :form when 'result' then :result when 'submit' then :submit else nil end end
Set the type (see type)
# File lib/xmpp4r/dataforms/x/data.rb, line 61 def type=(t) case t when :cancel then attributes['type'] = 'cancel' when :form then attributes['type'] = 'form' when :result then attributes['type'] = 'result' when :submit then attributes['type'] = 'submit' else attributes['type'] = nil end end