Sha256: ef0f3fc3f52c8c1c20377422c032677ce1938b4157ed9768162de97f35b276f1

Contents?: true

Size: 756 Bytes

Versions: 9

Compression:

Stored size: 756 Bytes

Contents

require "nokogiri"

module EPUB
  class Parser
    class XMLDocument
      module Refinements
        module Nokogiri
          refine ::Nokogiri::XML::Node do
            def each_element_by_xpath(xpath, namespaces = nil, &block)
              xpath(xpath, namespaces).each &block
            end

            def attribute_with_prefix(name, prefix = nil)
              attribute_with_ns(name, EPUB::NAMESPACES[prefix])&.value
            end

            def each_element(xpath = nil, &block)
              element_children.each(&block)
            end

            alias elements element_children

            def namespace_uri
              namespace.href
            end
          end
        end

        include Nokogiri
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
epub-parser-0.4.8 lib/epub/parser/xml_document/refinements/nokogiri.rb
epub-parser-0.4.7 lib/epub/parser/xml_document/refinements/nokogiri.rb
epub-parser-0.4.6 lib/epub/parser/xml_document/refinements/nokogiri.rb
epub-parser-0.4.5 lib/epub/parser/xml_document/refinements/nokogiri.rb
epub-parser-0.4.4 lib/epub/parser/xml_document/refinements/nokogiri.rb
epub-parser-0.4.3 lib/epub/parser/xml_document/refinements/nokogiri.rb
epub-parser-0.4.2 lib/epub/parser/xml_document/refinements/nokogiri.rb
epub-parser-0.4.1 lib/epub/parser/xml_document/refinements/nokogiri.rb
epub-parser-0.4.0 lib/epub/parser/xml_document/refinements/nokogiri.rb