Class Jabber::Dataforms::XDataField
In: lib/xmpp4r/dataforms/x/data.rb
Parent: XMPPElement
Message Presence XMPPStanza Iq Singleton IdGenerator XMPPElement X IqQuery Error Connection Client Component Client Comparable JID RuntimeError AuthenticationFailure ErrorException NoNameXmlnsRegistered SOCKS5Error REXML::Element Stream SOCKS5Bytestreams SOCKS5BytestreamsTarget SOCKS5BytestreamsInitiator XMPPElement StreamHost IqSiFileRange IqSiFile StreamHostUsed IqSi XRosterItem RosterItem IqFeature XMUCUserItem XMUCUserInvite IqPubSub Items Subscription IqPubSubOwner Item Event Feature Item Identity XDataField XDataReported XDataTitle XDataInstructions IqVcard SOCKS5BytestreamsServerStreamHost TCPSocket SOCKS5Socket IqQuery IqQueryBytestreams IqQueryVersion IqQueryRoster IqQueryMUCOwner IqQueryRPC IqQueryDiscoItems IqQueryDiscoInfo IBB IBBTarget IBBInitiator Responder SimpleResponder Iq IqCommand RosterXItem XRoster RosterX X XMUCUser XMUC XDelay XData XParent MUCClient SimpleMUCClient XMLRPC::ParserWriterChooseMixin Client Server XMLRPC::ParseContentType XMLRPC::BasicServer Base DigestMD5 Plain ServiceHelper NodeHelper FileSource CallbackList Callback Semaphore StreamParser SOCKS5BytestreamsPeer SOCKS5BytestreamsServer IBBQueueItem Responder Helper MUCBrowser NodeBrowser Helper Helper lib/xmpp4r/authenticationfailure.rb lib/xmpp4r/xmppstanza.rb lib/xmpp4r/callbacks.rb lib/xmpp4r/idgenerator.rb lib/xmpp4r/connection.rb lib/xmpp4r/iq.rb lib/xmpp4r/jid.rb lib/xmpp4r/errorexception.rb lib/xmpp4r/client.rb lib/xmpp4r/stream.rb lib/xmpp4r/semaphore.rb lib/xmpp4r/streamparser.rb lib/xmpp4r/x.rb lib/xmpp4r/error.rb lib/xmpp4r/component.rb lib/xmpp4r/query.rb lib/xmpp4r/xmppelement.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/server.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.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 XParent lib/xmpp4r/version/iq/version.rb lib/xmpp4r/version/helper/responder.rb lib/xmpp4r/version/helper/simpleresponder.rb Version lib/xmpp4r/command/iq/command.rb lib/xmpp4r/command/helper/responder.rb Command 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/iq/mucowner.rb lib/xmpp4r/muc/helper/simplemucclient.rb MUC lib/xmpp4r/rpc/helper/server.rb lib/xmpp4r/rpc/helper/client.rb lib/xmpp4r/rpc/iq/rpc.rb RPC lib/xmpp4r/sasl.rb SASL lib/xmpp4r/delay/x/delay.rb Delay lib/xmpp4r/pubsub/stanzas/subscription.rb lib/xmpp4r/pubsub/helper/servicehelper.rb lib/xmpp4r/pubsub/stanzas/item.rb lib/xmpp4r/pubsub/helper/nodehelper.rb lib/xmpp4r/pubsub/iq/pubsub.rb lib/xmpp4r/pubsub/stanzas/event.rb lib/xmpp4r/pubsub/helper/nodebrowser.rb lib/xmpp4r/pubsub/stanzas/items.rb PubSub lib/xmpp4r/httpbinding/client.rb HTTPBinding lib/xmpp4r/bytestreams/helper/filetransfer.rb TransferSource FileTransfer lib/xmpp4r/discovery/iq/discoinfo.rb lib/xmpp4r/discovery/iq/discoitems.rb Discovery lib/xmpp4r/dataforms/x/data.rb Dataforms lib/xmpp4r/vcard/helper/vcard.rb lib/xmpp4r/vcard/iq/vcard.rb Vcard Jabber dot/m_80_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 147
147:       def initialize(var=nil, type=nil)
148:         super()
149:         self.var = var
150:         self.type = type
151:       end

Public Instance methods

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 153
153:       def label
154:         attributes['label']
155:       end

[Source]

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

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

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 256
256:       def options
257:         res = {}
258:         each_element('option') { |e|
259:           value = nil
260:           e.each_element('value') { |ve| value = ve.text }
261:           res[value] = e.attributes['label']
262:         }
263:         res
264:       end

Set the options

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 268
268:       def options=(hsh)
269:         delete_elements('option')
270:         hsh.each { |value,label|
271:           o = add(REXML::Element.new('option'))
272:           o.attributes['label'] = label
273:           o.add(REXML::Element.new('value')).text = value
274:         }
275:       end

Set if this field is required

r:[true] or [false]

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 228
228:       def required=(r)
229:         delete_elements('required')
230:         if r
231:           add REXML::Element.new('required')
232:         end
233:       end

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

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 219
219:       def required?
220:         res = false
221:         each_element('required') { res = true }
222:         res
223:       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 183
183:       def type
184:         case attributes['type']
185:           when 'boolean' then :boolean
186:           when 'fixed' then :fixed
187:           when 'hidden' then :hidden
188:           when 'jid-multi' then :jid_multi
189:           when 'jid-single' then :jid_single
190:           when 'list-multi' then :list_multi
191:           when 'list-single' then :list_single
192:           when 'text-multi' then :text_multi
193:           when 'text-private' then :text_private
194:           when 'text-single' then :text_single
195:           else nil
196:         end
197:       end

Set the type of this field (see type)

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 201
201:       def type=(t)
202:         case t
203:           when :boolean then attributes['type'] = 'boolean'
204:           when :fixed then attributes['type'] = 'fixed'
205:           when :hidden then attributes['type'] = 'hidden'
206:           when :jid_multi then attributes['type'] = 'jid-multi'
207:           when :jid_single then attributes['type'] = 'jid-single'
208:           when :list_multi then attributes['type'] = 'list-multi'
209:           when :list_single then attributes['type'] = 'list-single'
210:           when :text_multi then attributes['type'] = 'text-multi'
211:           when :text_private then attributes['type'] = 'text-private'
212:           when :text_single then attributes['type'] = 'text-single'
213:           else attributes['type'] = nil
214:         end
215:       end

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

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 237
237:       def values
238:         res = []
239:         each_element('value') { |e|
240:           res << e.text
241:         }
242:         res
243:       end

Set the values

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 247
247:       def values=(ary)
248:         delete_elements('value')
249:         ary.each { |v|
250:           add(REXML::Element.new('value')).text = v
251:         }
252:       end

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 161
161:       def var
162:         attributes['var']
163:       end

[Source]

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

[Validate]