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