Class Jabber::Dataforms::XDataField
In: lib/xmpp4r/dataforms/x/data.rb
Parent: REXML::Element
XMLStanza Message Presence Iq REXML::Element X IqQuery Error StreamHost IqSiFileRange IqSiFile StreamHostUsed IqSi XRosterItem RosterItem IqFeature XMUCUserItem XMUCUserInvite XDataField XDataReported XDataTitle XDataInstructions Feature Identity Item IqVcard Singleton IdGenerator Connection Client Component Comparable JID RuntimeError AuthenticationFailure ErrorException SOCKS5Error Stream SOCKS5Bytestreams SOCKS5BytestreamsTarget SOCKS5BytestreamsInitiator SOCKS5BytestreamsServerStreamHost TCPSocket SOCKS5Socket IBB IBBTarget IBBInitiator IqQuery IqQueryBytestreams IqQueryVersion IqQueryRoster IqQueryDiscoItems IqQueryDiscoInfo Responder SimpleResponder X XRoster XMUCUser XMUC XDelay XData MUCClient SimpleMUCClient Base DigestMD5 Plain FileSource StreamParser SOCKS5BytestreamsPeer SOCKS5BytestreamsServer IBBQueueItem Helper MUCBrowser Helper Helper lib/xmpp4r/authenticationfailure.rb lib/xmpp4r/idgenerator.rb lib/xmpp4r/connection.rb lib/xmpp4r/iq.rb lib/xmpp4r/jid.rb lib/xmpp4r/xmlstanza.rb lib/xmpp4r/errorexception.rb lib/xmpp4r/stream.rb lib/xmpp4r/client.rb lib/xmpp4r/x.rb lib/xmpp4r/streamparser.rb lib/xmpp4r/error.rb lib/xmpp4r/component.rb lib/xmpp4r/query.rb lib/xmpp4r/message.rb lib/xmpp4r/presence.rb lib/xmpp4r/bytestreams/helper/ibb/initiator.rb lib/xmpp4r/bytestreams/iq/si.rb lib/xmpp4r/bytestreams/iq/bytestreams.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb lib/xmpp4r/bytestreams/helper/ibb/base.rb lib/xmpp4r/bytestreams/helper/ibb/target.rb Bytestreams lib/xmpp4r/version/iq/version.rb lib/xmpp4r/version/helper/responder.rb lib/xmpp4r/version/helper/simpleresponder.rb Version lib/xmpp4r/roster/helper/roster.rb lib/xmpp4r/roster/iq/roster.rb lib/xmpp4r/roster/x/roster.rb Roster lib/xmpp4r/feature_negotiation/iq/feature.rb FeatureNegotiation lib/xmpp4r/muc/x/muc.rb lib/xmpp4r/muc/helper/mucclient.rb lib/xmpp4r/muc/x/mucuseritem.rb lib/xmpp4r/muc/helper/mucbrowser.rb lib/xmpp4r/muc/x/mucuserinvite.rb lib/xmpp4r/muc/helper/simplemucclient.rb MUC lib/xmpp4r/sasl.rb SASL lib/xmpp4r/bytestreams/helper/filetransfer.rb TransferSource FileTransfer lib/xmpp4r/delay/x/delay.rb Delay lib/xmpp4r/dataforms/x/data.rb Dataforms lib/xmpp4r/discovery/iq/discoinfo.rb lib/xmpp4r/discovery/iq/discoitems.rb Discovery lib/xmpp4r/vcard/helper/vcard.rb lib/xmpp4r/vcard/iq/vcard.rb Vcard Jabber dot/m_60_0.png

Child of XData, contains configurable/configured options of this Data Form

Methods

label   label=   new   options   options=   required=   required?   type   type=   values   values=   var   var=  

Public Class methods

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 108
108:       def initialize(var=nil, type=nil)
109:         super('field')
110:         self.var = var
111:         self.type = type
112:       end

Public Instance methods

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 114
114:       def label
115:         attributes['label']
116:       end

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 118
118:       def label=(s)
119:         attributes['label'] = s
120:       end

Get the options (in a Data Form with type=‘form’)

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 217
217:       def options
218:         res = {}
219:         each_element('option') { |e|
220:           value = nil
221:           e.each_element('value') { |ve| value = ve.text }
222:           res[value] = e.attributes['label']
223:         }
224:         res
225:       end

Set the options

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 229
229:       def options=(hsh)
230:         delete_elements('option')
231:         hsh.each { |value,label|
232:           o = add(REXML::Element.new('option'))
233:           o.attributes['label'] = label
234:           o.add(REXML::Element.new('value')).text = value
235:         }
236:       end

Set if this field is required

r:[true] or [false]

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 189
189:       def required=(r)
190:         delete_elements('required')
191:         if r
192:           add REXML::Element.new('required')
193:         end
194:       end

Is this field required (has the <required/> child)?

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 180
180:       def required?
181:         res = false
182:         each_element('required') { res = true }
183:         res
184:       end

Type of this field

result:* :boolean
  • :fixed
  • :hidden
  • :jid_multi
  • :jid_single
  • :list_multi
  • :list_single
  • :text_multi
  • :text_private
  • :text_single
  • nil

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 144
144:       def type
145:         case attributes['type']
146:           when 'boolean' then :boolean
147:           when 'fixed' then :fixed
148:           when 'hidden' then :hidden
149:           when 'jid-multi' then :jid_multi
150:           when 'jid-single' then :jid_single
151:           when 'list-multi' then :list_multi
152:           when 'list-single' then :list_single
153:           when 'text-multi' then :text_multi
154:           when 'text-private' then :text_private
155:           when 'text-single' then :text_single
156:           else nil
157:         end
158:       end

Set the type of this field (see type)

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 162
162:       def type=(t)
163:         case t
164:           when :boolean then attributes['type'] = 'boolean'
165:           when :fixed then attributes['type'] = 'fixed'
166:           when :hidden then attributes['type'] = 'hidden'
167:           when :jid_multi then attributes['type'] = 'jid-multi'
168:           when :jid_single then attributes['type'] = 'jid-single'
169:           when :list_multi then attributes['type'] = 'list-multi'
170:           when :list_single then attributes['type'] = 'list-single'
171:           when :text_multi then attributes['type'] = 'text-multi'
172:           when :text_private then attributes['type'] = 'text-private'
173:           when :text_single then attributes['type'] = 'text-single'
174:           else attributes['type'] = nil
175:         end
176:       end

Get the values (in a Data Form with type=‘submit’)

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 198
198:       def values
199:         res = []
200:         each_element('value') { |e|
201:           res << e.text
202:         }
203:         res
204:       end

Set the values

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 208
208:       def values=(ary)
209:         delete_elements('value')
210:         ary.each { |v|
211:           add(REXML::Element.new('value')).text = v
212:         }
213:       end

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 122
122:       def var
123:         attributes['var']
124:       end

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 126
126:       def var=(s)
127:         attributes['var'] = s
128:       end

[Validate]