class Jabber::Dataforms::XData

Data Forms (JEP-0004) implementation

Public Class Methods

new(type=nil) click to toggle source
Calls superclass method
# File lib/xmpp4r/dataforms/x/data.rb, line 15
def initialize(type=nil)
  super()
  self.type = type
end

Public Instance Methods

field(var) click to toggle source

Search a field by it's var-name

var
String
result
XDataField

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
fields(including_hidden=false) click to toggle source
# 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
instructions() click to toggle source

Get the Data Form instructions

return
Array

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
instructions=(i) click to toggle source

Add Data Form instructions

i
String
# File lib/xmpp4r/dataforms/x/data.rb, line 100
def instructions=(i)
  add(XDataInstructions.new(i))
end
title() click to toggle source

Get the Data Form title

return
XDataTitle

or nil

# File lib/xmpp4r/dataforms/x/data.rb, line 74
def title
  first_element('title')
end
title=(title) click to toggle source

Set the Data Form title

title
String
# File lib/xmpp4r/dataforms/x/data.rb, line 81
def title=(title)
  delete_elements('title')
  add_element(XDataTitle.new(title))
end
type() click to toggle source

Type of this Data Form

result
  • :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
type=(t) click to toggle source

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