Class: EPUB::ContentDocument::XHTML
- Inherits:
-
Object
- Object
- EPUB::ContentDocument::XHTML
- Defined in:
- lib/epub/content_document/xhtml.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#item ⇒ Object
Returns the value of attribute item.
Instance Method Summary collapse
-
#nokogiri ⇒ Nokogiri::XML::Document
Content as Nokogiri::XML::Document object.
-
#read ⇒ String
(also: #raw_document)
Returns the content string.
-
#rexml ⇒ REXML::Document
Content as REXML::Document object.
-
#title ⇒ String
Returns the value of title element.
-
#top_level? ⇒ true|false
Whether referenced directly from spine or not.
Instance Attribute Details
#item ⇒ Object
Returns the value of attribute item.
4 5 6 |
# File 'lib/epub/content_document/xhtml.rb', line 4 def item @item end |
Instance Method Details
#nokogiri ⇒ Nokogiri::XML::Document
Returns content as Nokogiri::XML::Document object.
36 37 38 |
# File 'lib/epub/content_document/xhtml.rb', line 36 def nokogiri @nokogiri ||= Nokogiri.XML(raw_document) end |
#read ⇒ String Also known as: raw_document
Returns the content string.
7 8 9 |
# File 'lib/epub/content_document/xhtml.rb', line 7 def read item.read end |
#rexml ⇒ REXML::Document
Returns content as REXML::Document object.
30 31 32 33 |
# File 'lib/epub/content_document/xhtml.rb', line 30 def rexml require 'rexml/document' @rexml ||= REXML::Document.new(raw_document) end |
#title ⇒ String
Returns the value of title element. If none, returns empty string
19 20 21 22 23 24 25 26 27 |
# 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? ⇒ true|false
Returns Whether referenced directly from spine or not.
13 14 15 |
# File 'lib/epub/content_document/xhtml.rb', line 13 def top_level? !! item.itemref end |