### Home Classes Methods

### In Files

- lib/xmpp4r/dataforms/x/data.rb

### Parent

XMPPElement

### Methods

- ::new
- #label
- #label=
- #options
- #options=
- #required=
- #required?
- #type
- #type=
- #value
- #value=
- #values
- #values=
- #var
- #var=

### Files

- CHANGELOG
- COPYING
- LICENSE
- README.rdoc
- README_ruby19.txt

### Class/Module Index

Quicksearch

- Jabber
- Jabber::ArgumentError
- Jabber::Bytestreams
- Jabber::Bytestreams::IBB
- Jabber::Bytestreams::IBBInitiator
- Jabber::Bytestreams::IBBQueueItem
- Jabber::Bytestreams::IBBTarget
- Jabber::Bytestreams::IqQueryBytestreams
- Jabber::Bytestreams::IqSi
- Jabber::Bytestreams::IqSiFile
- Jabber::Bytestreams::IqSiFileRange
- Jabber::Bytestreams::SOCKS5Bytestreams
- Jabber::Bytestreams::SOCKS5BytestreamsInitiator
- Jabber::Bytestreams::SOCKS5BytestreamsPeer
- Jabber::Bytestreams::SOCKS5BytestreamsServer
- Jabber::Bytestreams::SOCKS5BytestreamsServerStreamHost
- Jabber::Bytestreams::SOCKS5BytestreamsTarget
- Jabber::Bytestreams::SOCKS5Socket
- Jabber::Bytestreams::StreamHost
- Jabber::Bytestreams::StreamHostUsed
- Jabber::Callback
- Jabber::CallbackList
- Jabber::Caps
- Jabber::Caps::C
- Jabber::Caps::Helper
- Jabber::Client
- Jabber::ClientAuthenticationFailure
- Jabber::Command
- Jabber::Command::IqCommand
- Jabber::Command::Responder
- Jabber::Component
- Jabber::ComponentAuthenticationFailure
- Jabber::Connection
- Jabber::Connection::SSLSocketUTF8
- Jabber::Dataforms
- Jabber::Dataforms::XData
- Jabber::Dataforms::XDataField
- Jabber::Dataforms::XDataInstructions
- Jabber::Dataforms::XDataReported
- Jabber::Dataforms::XDataTitle
- Jabber::Delay
- Jabber::Delay::XDelay
- Jabber::Discovery
- Jabber::Discovery::Feature
- Jabber::Discovery::Helper
- Jabber::Discovery::Identity
- Jabber::Discovery::IqQueryDiscoInfo
- Jabber::Discovery::IqQueryDiscoItems
- Jabber::Discovery::Item
- Jabber::Discovery::Responder
- Jabber::EntityTime
- Jabber::EntityTime::IqTime
- Jabber::EntityTime::Responder
- Jabber::ErrorResponse
- Jabber::FeatureNegotiation
- Jabber::FeatureNegotiation::IqFeature
- Jabber::FileTransfer
- Jabber::FileTransfer::FileSource
- Jabber::FileTransfer::Helper
- Jabber::FileTransfer::TransferSource
- Jabber::Framework
- Jabber::Framework::Base
- Jabber::Framework::Bot
- Jabber::HTTPBinding
- Jabber::HTTPBinding::Client
- Jabber::IdGenerator
- Jabber::InvalidChatState
- Jabber::Iq
- Jabber::IqQuery
- Jabber::JID
- Jabber::JabberError
- Jabber::LastActivity
- Jabber::LastActivity::Helper
- Jabber::LastActivity::IqQueryLastActivity
- Jabber::MUC
- Jabber::MUC::IqQueryMUCAdmin
- Jabber::MUC::IqQueryMUCAdminItem
- Jabber::MUC::IqQueryMUCOwner
- Jabber::MUC::MUCBrowser
- Jabber::MUC::MUCClient
- Jabber::MUC::SimpleMUCClient
- Jabber::MUC::UserItem
- Jabber::MUC::XMUC
- Jabber::MUC::XMUCUser
- Jabber::MUC::XMUCUserInvite
- Jabber::MUC::XMUCUserItem
- Jabber::Message
- Jabber::NoNameXmlnsRegistered
- Jabber::NotConnected
- Jabber::Observable
- Jabber::Observable::Contact
- Jabber::Observable::PubSub
- Jabber::Observable::PubSub::AlreadySet
- Jabber::Observable::PubSub::NoService
- Jabber::Observable::Subscriptions
- Jabber::Presence
- Jabber::PubSub
- Jabber::PubSub::Configuration
- Jabber::PubSub::Event
- Jabber::PubSub::EventItem
- Jabber::PubSub::EventItems
- Jabber::PubSub::IqPubSub
- Jabber::PubSub::IqPubSubOwner
- Jabber::PubSub::Item
- Jabber::PubSub::Items
- Jabber::PubSub::NodeBrowser
- Jabber::PubSub::NodeConfig
- Jabber::PubSub::NodeHelper
- Jabber::PubSub::OAuthPubSubStreamHelper
- Jabber::PubSub::OAuthServiceHelper
- Jabber::PubSub::OwnerNodeConfig
- Jabber::PubSub::Publish
- Jabber::PubSub::Retract
- Jabber::PubSub::ServiceHelper
- Jabber::PubSub::Subscription
- Jabber::PubSub::SubscriptionConfig
- Jabber::PubSub::Unsubscribe
- Jabber::RPC
- Jabber::RPC::Client
- Jabber::RPC::IqQueryRPC
- Jabber::RPC::Server
- Jabber::Reliable
- Jabber::Reliable::Connection
- Jabber::Reliable::Listener
- Jabber::Roster
- Jabber::Roster::Helper
- Jabber::Roster::Helper::RosterItem
- Jabber::Roster::IqQueryRoster
- Jabber::Roster::RosterItem
- Jabber::Roster::RosterX
- Jabber::Roster::RosterXItem
- Jabber::Roster::XRoster
- Jabber::Roster::XRosterItem
- Jabber::SASL
- Jabber::SASL::Anonymous
- Jabber::SASL::Base
- Jabber::SASL::DigestMD5
- Jabber::SASL::Plain
- Jabber::SOCKS5Error
- Jabber::Semaphore
- Jabber::ServerDisconnected
- Jabber::Stream
- Jabber::Stream::ThreadBlock
- Jabber::StreamParser
- Jabber::Test
- Jabber::Test::ListenerMocker
- Jabber::UserLocation
- Jabber::UserLocation::Helper
- Jabber::UserLocation::Location
- Jabber::UserTune
- Jabber::UserTune::Helper
- Jabber::UserTune::Tune
- Jabber::Vcard
- Jabber::Vcard::Helper
- Jabber::Vcard::IqVcard
- Jabber::Version
- Jabber::Version::IqQueryVersion
- Jabber::Version::Responder
- Jabber::Version::SimpleResponder
- Jabber::X
- Jabber::XHTML
- Jabber::XHTML::Body
- Jabber::XHTML::HTML
- Jabber::XMPPElement
- Jabber::XMPPStanza
- Jabber::XParent
- REXML
- REXML::Element
- REXML::IOSource
- XMLRPC
- XMLRPC::Create
- Base64
- ObservableThing
- QObserver
- ThreadStore

No matching classes.

# Jabber::Dataforms::XDataField

Child of XData, contains configurable/configured options of this Data Form

### Public Class Methods

new(var=nil, type=nil) click to toggle source

    # File lib/xmpp4r/dataforms/x/data.rb, line 148
    def initialize(var=nil, type=nil)
      super()
      self.var = var
      self.type = type
    end

### Public Instance Methods

label() click to toggle source

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

label=(s) click to toggle source

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

options() click to toggle source

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

    # File lib/xmpp4r/dataforms/x/data.rb, line 269
    def options
      res = {}
      each_element('option') { |e|
        value = nil
        e.each_element('value') { |ve| value = ve.text }
        res[value] = e.attributes['label']
      }
      res
    end

options=(hsh) click to toggle source

Set the options

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

required=(r) click to toggle source

Set if this field is required

r

true

  or [false]

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

required?() click to toggle source

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

    # File lib/xmpp4r/dataforms/x/data.rb, line 220
    def required?
      res = false
      each_element('required') { res = true }
      res
    end

type() click to toggle source

Type of this field

result

- :boolean

- :fixed

- :hidden

- :jid_multi

- :jid_single

- :list_multi

- :list_single

- :text_multi

- :text_private

- :text_single

- nil

    # File lib/xmpp4r/dataforms/x/data.rb, line 184
    def type
      case attributes['type']
        when 'boolean' then :boolean
        when 'fixed' then :fixed
        when 'hidden' then :hidden
        when 'jid-multi' then :jid_multi
        when 'jid-single' then :jid_single
        when 'list-multi' then :list_multi
        when 'list-single' then :list_single
        when 'text-multi' then :text_multi
        when 'text-private' then :text_private
        when 'text-single' then :text_single
        else nil
      end
    end

type=(t) click to toggle source

Set the type of this field (see type)

    # File lib/xmpp4r/dataforms/x/data.rb, line 202
    def type=(t)
      case t
        when :boolean then attributes['type'] = 'boolean'
        when :fixed then attributes['type'] = 'fixed'
        when :hidden then attributes['type'] = 'hidden'
        when :jid_multi then attributes['type'] = 'jid-multi'
        when :jid_single then attributes['type'] = 'jid-single'
        when :list_multi then attributes['type'] = 'list-multi'
        when :list_single then attributes['type'] = 'list-single'
        when :text_multi then attributes['type'] = 'text-multi'
        when :text_private then attributes['type'] = 'text-private'
        when :text_single then attributes['type'] = 'text-single'
        else attributes['type'] = nil
      end
    end

value() click to toggle source

Get the first value

    # File lib/xmpp4r/dataforms/x/data.rb, line 257
    def value
      values.first
    end

value=(val) click to toggle source

Remove all and set one value

    # File lib/xmpp4r/dataforms/x/data.rb, line 263
    def value=(val)
      self.values = [val]
    end

values() click to toggle source

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

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

values=(ary) click to toggle source

Set the values

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

var() click to toggle source

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

var=(s) click to toggle source

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.