Class | Jabber::Dataforms::XDataField |
In: |
lib/xmpp4r/dataforms/x/data.rb
|
Parent: | XMPPElement |
# 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
# File lib/xmpp4r/dataforms/x/data.rb, line 157 157: def label=(s) 158: attributes['label'] = s 159: end
Set the options
# 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] |
# 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)?
# 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
|
# 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)
# 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