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 36
def nokogiri
  @nokogiri ||= Nokogiri.XML(raw_document)
end
raw_document()
Alias for: read
read() click to toggle source

@return [String] Returns the content string.

# File lib/epub/content_document/xhtml.rb, line 7
def read
  item.read
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 30
def rexml
  require 'rexml/document'
  @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 19
def title
  title_elem = nokogiri.search('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 13
def top_level?
  !! item.itemref
end