Sha256: e6b3833b50e05a9eeaf277ca888665f585e6a6bd6c97209ded8c7fc169bbe9ba

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

module Nokogiri
  module XML
    class Namespace # :nodoc:

      attr_accessor :cstruct # :nodoc:
      attr_accessor :document # :nodoc:

      def prefix  # :nodoc:
        cstruct[:prefix].nil? ? nil : cstruct[:prefix] # TODO: encoding?
      end

      def href # :nodoc:
        cstruct[:href].nil? ? nil : cstruct[:href] # TODO: encoding?
      end

      class << self
        def wrap(document, node_struct) # :nodoc:
          if node_struct.is_a?(FFI::Pointer)
            # cast native pointers up into a node cstruct
            return nil if node_struct.null?
            node_struct = LibXML::XmlNs.new(node_struct) 
          end

          ruby_node = node_struct.ruby_node
          return ruby_node unless ruby_node.nil?

          ns = Nokogiri::XML::Namespace.allocate
          ns.document = document.ruby_doc
          ns.cstruct = node_struct
          
          ns.cstruct.ruby_node = ns

          cache = ns.document.instance_variable_get(:@node_cache)
          cache << ns

          ns
        end
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nokogiri-1.3.1-x86-mingw32 lib/nokogiri/ffi/xml/namespace.rb
nokogiri-1.3.1-java lib/nokogiri/ffi/xml/namespace.rb
nokogiri-1.3.1 lib/nokogiri/ffi/xml/namespace.rb
nokogiri-1.3.1-x86-mswin32 lib/nokogiri/ffi/xml/namespace.rb