module EPUB::Parser::XMLDocument::Refinements::Oga

Public Instance Methods

attribute_with_prefix(name, prefix = nil) click to toggle source
# File lib/epub/parser/xml_document/refinements/oga.rb, line 42
def attribute_with_prefix(name, prefix = nil)
  name = prefix ? "#{prefix}:#{name}" : name
  get(name)
end
each_element(xpath = nil, &block) click to toggle source
# File lib/epub/parser/xml_document/refinements/oga.rb, line 47
def each_element(xpath = nil, &block)
  each_node do |node|
    throw :skip_children unless node.kind_of?(::Oga::XML::Element)
    block.call node
  end
end
each_element_by_xpath(xpath, namespaces = nil, &block) click to toggle source
# File lib/epub/parser/xml_document/refinements/oga.rb, line 35
def each_element_by_xpath(xpath, namespaces = nil, &block)
  xpath(xpath, namespaces: namespaces).each &block
end
elements() click to toggle source
# File lib/epub/parser/xml_document/refinements/oga.rb, line 25
def elements
  # Couldn't use find(&:element?) for Rubies under 2.6
  children.select {|child| child.element?}
end
namespace_uri() click to toggle source
# File lib/epub/parser/xml_document/refinements/oga.rb, line 54
def namespace_uri
  namespace&.uri
end
namespaces() click to toggle source
# File lib/epub/parser/xml_document/refinements/oga.rb, line 59
def namespaces
  original_namespaces.each_with_object({}) {|(name, namespace), nss|
    nss[name] = namespace.uri
  }
end
Also aliased as: original_namespaces
original_namespaces()
Alias for: namespaces
respond_to?(name, include_all = false) click to toggle source

Need for Rubies under 2.6

Calls superclass method
# File lib/epub/parser/xml_document/refinements/oga.rb, line 31
def respond_to?(name, include_all = false)
  [:root, :elements].include?(name) || super
end
root() click to toggle source
# File lib/epub/parser/xml_document/refinements/oga.rb, line 20
def root
  # Couldn't use find(&:element?) for Rubies under 2.6
  root_node.children.find {|child| child.element?}
end