Sha256: 193e7e38d5cd5614c546312e2adada00cdda9eddc4d2e1127822b1e6aa2f12b2

Contents?: true

Size: 1.3 KB

Versions: 22

Compression:

Stored size: 1.3 KB

Contents

module LibXML
  module XML
    class Namespace
      include Comparable
      include Enumerable

      # call-seq:
      #   namespace1 <=> namespace2
      #
      # Compares two namespace objects.  Namespace objects are
      # considered equal if their prefixes and hrefs are the same.
      def <=>(other)
        if self.prefix.nil? and other.prefix.nil?
          self.href <=> other.href
        elsif self.prefix.nil?
          -1
        elsif other.prefix.nil?
          1
        else
          self.prefix <=> other.prefix
        end
      end

      # call-seq:
      #   namespace.each {|ns| .. }
      #
      # libxml stores namespaces in memory as a linked list.
      # Use the each method to iterate over the list.  Note
      # the first namespace in the loop is the current namespace.
      #
      # Usage:
      #   namespace.each do |ns|
      #     ..
      #   end
      def each
        ns = self

        while ns
          yield ns
          ns = ns.next
        end
      end

      # call-seq:
      #   namespace.to_s -> "string"
      #
      # Returns the string represenation of a namespace.
      #
      # Usage:
      #   namespace.to_s
      def to_s
        if self.prefix
          "#{self.prefix}:#{self.href}"
        else
          self.href
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 3 rubygems

Version Path
libxml-ruby-r19mingw-1.1.4 lib/libxml/namespace.rb
libxml-ruby-1.1.4 lib/libxml/namespace.rb
libxml-ruby-1.1.4-x86-mswin32-60 lib/libxml/namespace.rb
coupa-libxml-ruby-1.1.4 lib/libxml/namespace.rb
libxml-ruby-0.9.6-x86-mswin32-60 lib/libxml/namespace.rb
libxml-ruby-0.9.6 lib/libxml/namespace.rb
libxml-ruby-0.9.7-x86-mswin32-60 lib/libxml/namespace.rb
libxml-ruby-0.9.7 lib/libxml/namespace.rb
libxml-ruby-0.9.9 lib/libxml/namespace.rb
libxml-ruby-0.9.9-x86-mswin32-60 lib/libxml/namespace.rb
libxml-ruby-0.9.8 lib/libxml/namespace.rb
libxml-ruby-0.9.8-x86-mswin32-60 lib/libxml/namespace.rb
libxml-ruby-1.0.0 lib/libxml/namespace.rb
libxml-ruby-1.0.0-x86-mswin32-60 lib/libxml/namespace.rb
libxml-ruby-1.1.0 lib/libxml/namespace.rb
libxml-ruby-1.1.0-x86-mswin32-60 lib/libxml/namespace.rb
libxml-ruby-1.1.1-x86-mswin32-60 lib/libxml/namespace.rb
libxml-ruby-1.1.2-x86-mswin32-60 lib/libxml/namespace.rb
libxml-ruby-1.1.3-x86-mswin32-60 lib/libxml/namespace.rb
libxml-ruby-1.1.1 lib/libxml/namespace.rb