class EPUB::ContentDocument::XHTML

Attributes

item[RW]

Public Instance Methods

nokogiri() click to toggle source

@return [Nokogiri::XML::Document] content as Nokogiri::XML::Document object

# File lib/epub/content_document/xhtml.rb, line 42
def nokogiri
  require 'nokogiri'
  @nokogiri ||= Nokogiri.XML(raw_document)
end
oga() click to toggle source

@return [Oga::XML::Document] content as Oga::XML::Document object

# File lib/epub/content_document/xhtml.rb, line 36
def oga
  require "oga"
  @oga ||= Oga.parse_xml(raw_document)
end
raw_document(detect_encoding: true)
Alias for: read
read(detect_encoding: true) click to toggle source

@param [Boolean] detect_encoding See {Publication::Package::Manifest::Item#read} @return [String] Returns the content string.

# File lib/epub/content_document/xhtml.rb, line 8
def read(detect_encoding: true)
  item.read(detect_encoding: detect_encoding)
end
Also aliased as: raw_document
rexml() click to toggle source

@return [REXML::Document] content as REXML::Document object

# File lib/epub/content_document/xhtml.rb, line 31
def rexml
  @rexml ||= REXML::Document.new(raw_document)
end
title() click to toggle source

@return [String] Returns the value of title element.

If none, returns empty string
# File lib/epub/content_document/xhtml.rb, line 20
def title
  title_elem = rexml.get_elements('.//title').first
  if title_elem
    title_elem.text
  else
    warn 'title element not found'
    ''
  end
end
top_level?() click to toggle source

@return [true|false] Whether referenced directly from spine or not.

# File lib/epub/content_document/xhtml.rb, line 14
def top_level?
  !! item.itemref
end