Class: Jabber::Dataforms::XData

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

new(type=nil)

[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

field(var)

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

fields(including_hidden=false)

[Source]

        # 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

instructions()

Get the Data Form instructions

return: | [Array] of [XDataInstructions] or nil

[Source]

        # 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

instructions=(i)

Add Data Form instructions

i: | [String]

[Source]

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

title()

Get the Data Form title

return: | [XDataTitle] or nil

[Source]

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

title=(title)

Set the Data Form title

title: | [String]

[Source]

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

type()

Type of this Data Form

result: | * :cancel :form :result :submit nil

[Source]

        # 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

type=(t)

Set the type (see type)

[Source]

        # 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

[Validate]