Sha256: 90bcf40dca8c5f5f88e6103fccd26d8a2ff0669e7b450aabe18482e435f7b10e

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

# =XMPP4R - XMPP Library for Ruby
# License:: Ruby's license (see the LICENSE file) or GNU GPL, at your option.
# Website::http://xmpp4r.github.io

require 'xmpp4r/xmppelement'

module Jabber
  ##
  # A class used to build/parse <x/> elements
  #
  # These elements may occur as "attachments"
  # in [Message] and [Presence] stanzas
  class X < XMPPElement
    name_xmlns 'x'
    force_xmlns true
  end

  module XParent
    ##
    # Get the first <x/> element in this stanza, or nil if none found.
    # wanted_xmlns:: [String] Optional, find the first <x/> element having this xmlns,
    # wanted_xmlns can also be a derivate of XMPPElement from which the namespace will be taken
    # result:: [REXML::Element] or nil
    def x(wanted_xmlns=nil)
      if wanted_xmlns.kind_of? Class and wanted_xmlns.ancestors.include? XMPPElement
        wanted_xmlns = wanted_xmlns.new.namespace
      end

        each_element('x') { |x|
        if wanted_xmlns.nil? or wanted_xmlns == x.namespace
          return x
        end
      }
      nil
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xmpp4r-0.5.6 lib/xmpp4r/x.rb