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 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/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_79_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 113
113:       def initialize(var=nil, type=nil)
114:         super()
115:         self.var = var
116:         self.type = type
117:       end

Public Instance methods

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 119
119:       def label
120:         attributes['label']
121:       end

[Source]

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

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

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 222
222:       def options
223:         res = {}
224:         each_element('option') { |e|
225:           value = nil
226:           e.each_element('value') { |ve| value = ve.text }
227:           res[value] = e.attributes['label']
228:         }
229:         res
230:       end

Set the options

[Source]

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

Set if this field is required

r:[true] or [false]

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 194
194:       def required=(r)
195:         delete_elements('required')
196:         if r
197:           add REXML::Element.new('required')
198:         end
199:       end

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

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 185
185:       def required?
186:         res = false
187:         each_element('required') { res = true }
188:         res
189:       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 149
149:       def type
150:         case attributes['type']
151:           when 'boolean' then :boolean
152:           when 'fixed' then :fixed
153:           when 'hidden' then :hidden
154:           when 'jid-multi' then :jid_multi
155:           when 'jid-single' then :jid_single
156:           when 'list-multi' then :list_multi
157:           when 'list-single' then :list_single
158:           when 'text-multi' then :text_multi
159:           when 'text-private' then :text_private
160:           when 'text-single' then :text_single
161:           else nil
162:         end
163:       end

Set the type of this field (see type)

[Source]

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

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

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 203
203:       def values
204:         res = []
205:         each_element('value') { |e|
206:           res << e.text
207:         }
208:         res
209:       end

Set the values

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 213
213:       def values=(ary)
214:         delete_elements('value')
215:         ary.each { |v|
216:           add(REXML::Element.new('value')).text = v
217:         }
218:       end

[Source]

     # File lib/xmpp4r/dataforms/x/data.rb, line 127
127:       def var
128:         attributes['var']
129:       end

[Source]

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

[Validate]