Sha256: d05cb2e4b58e062ded93d1654a52fce5496462db3268ebf2c0ee8cd52e6d049f
Contents?: true
Size: 1008 Bytes
Versions: 2
Compression:
Stored size: 1008 Bytes
Contents
require "rexml/document" module EPUB class Parser class XMLDocument module Refinements module REXML [::REXML::Element, ::REXML::Text].each do |klass| refine klass do %i[document element text].each do |type| define_method "#{type}?" do node_type == type end end end end refine ::REXML::Element do def each_element_by_xpath(xpath, namespaces = nil, &block) ::REXML::XPath.each self, xpath, namespaces, &block end def attribute_with_prefix(name, prefix = nil) attribute(name, EPUB::NAMESPACES[prefix])&.value end alias namespace_uri namespace def content texts.join end end refine ::REXML::Text do alias content value end end include REXML end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
epub-parser-0.4.1 | lib/epub/parser/xml_document/refinements/rexml.rb |
epub-parser-0.4.0 | lib/epub/parser/xml_document/refinements/rexml.rb |