Class | Jabber::Dataforms::XDataField |
In: |
lib/xmpp4r/dataforms/x/data.rb
|
Parent: | XMPPElement |
# File lib/xmpp4r/dataforms/x/data.rb, line 148 148: def initialize(var=nil, type=nil) 149: super() 150: self.var = var 151: self.type = type 152: end
# File lib/xmpp4r/dataforms/x/data.rb, line 158 158: def label=(s) 159: attributes['label'] = s 160: end
Set the options
# File lib/xmpp4r/dataforms/x/data.rb, line 281 281: def options=(hsh) 282: delete_elements('option') 283: hsh.each { |value,label| 284: o = add(REXML::Element.new('option')) 285: o.attributes['label'] = label 286: o.add(REXML::Element.new('value')).text = value 287: } 288: end
Set if this field is required
r: | [true] or [false] |
# File lib/xmpp4r/dataforms/x/data.rb, line 229 229: def required=(r) 230: delete_elements('required') 231: if r 232: add REXML::Element.new('required') 233: end 234: end
Is this field required (has the <required/> child)?
# File lib/xmpp4r/dataforms/x/data.rb, line 220 220: def required? 221: res = false 222: each_element('required') { res = true } 223: res 224: end
Type of this field
result: | * :boolean
|
# File lib/xmpp4r/dataforms/x/data.rb, line 184 184: def type 185: case attributes['type'] 186: when 'boolean' then :boolean 187: when 'fixed' then :fixed 188: when 'hidden' then :hidden 189: when 'jid-multi' then :jid_multi 190: when 'jid-single' then :jid_single 191: when 'list-multi' then :list_multi 192: when 'list-single' then :list_single 193: when 'text-multi' then :text_multi 194: when 'text-private' then :text_private 195: when 'text-single' then :text_single 196: else nil 197: end 198: end
Set the type of this field (see type)
# File lib/xmpp4r/dataforms/x/data.rb, line 202 202: def type=(t) 203: case t 204: when :boolean then attributes['type'] = 'boolean' 205: when :fixed then attributes['type'] = 'fixed' 206: when :hidden then attributes['type'] = 'hidden' 207: when :jid_multi then attributes['type'] = 'jid-multi' 208: when :jid_single then attributes['type'] = 'jid-single' 209: when :list_multi then attributes['type'] = 'list-multi' 210: when :list_single then attributes['type'] = 'list-single' 211: when :text_multi then attributes['type'] = 'text-multi' 212: when :text_private then attributes['type'] = 'text-private' 213: when :text_single then attributes['type'] = 'text-single' 214: else attributes['type'] = nil 215: end 216: end