Class: Kitchen::BookElement
- Inherits:
-
ElementBase
- Object
- ElementBase
- Kitchen::BookElement
- Defined in:
- lib/kitchen/book_element.rb
Overview
An element for an entire book
Instance Attribute Summary
Attributes inherited from ElementBase
#ancestors, #document, #enumerator_class, #search_query_that_found_me, #short_type
Class Method Summary collapse
-
.is_the_element_class_for?(node) ⇒ Boolean
Returns true if this class represents the element for the given node.
-
.short_type ⇒ Symbol
Returns the short type.
Instance Method Summary collapse
-
#body ⇒ Element
Returns the “body” element.
-
#initialize(node:, document: nil) ⇒ BookElement
constructor
Creates a new
BookElement
. -
#metadata ⇒ MetadataElement
Returns the top metadata element.
-
#toc ⇒ Element
Returns the table of contents (toc) element.
Methods inherited from ElementBase
#[], #[]=, #add_ancestor, #add_ancestors, #add_class, #ancestor, #ancestor_elements, #append, #as_enumerator, #children, #classes, #clone, #config, #contains?, #content, #copied_id, #copy, #count_in, #cut, #data_type, descendant, descendant!, #element_children, #first, #first!, #has_ancestor?, #has_class?, #href, #href=, #id, #id=, #inner_html=, #inspect, #is?, #key?, #mark_as_current_location!, #name, #name=, #pages, #pantry, #parent, #paste, #path, #preceded_by_text, #prepend, #previous, #raw, #raw_search, #remember_that_a_sub_element_was_counted, #remove_attribute, #remove_class, #replace_children, #search, #search_history, #selectors, #set, #sub_header_name, #target_label, #text, #to_html, #to_s, #to_xhtml, #to_xml, #trash, #uncount, #wrap, #wrap_children
Methods included from Mixins::BlockErrorIf
Constructor Details
#initialize(node:, document: nil) ⇒ BookElement
Creates a new BookElement
13 14 15 16 17 |
# File 'lib/kitchen/book_element.rb', line 13 def initialize(node:, document: nil) super(node: node, document: document, enumerator_class: BookElementEnumerator) end |
Class Method Details
.is_the_element_class_for?(node) ⇒ Boolean
Returns true if this class represents the element for the given node
55 56 57 |
# File 'lib/kitchen/book_element.rb', line 55 def self.is_the_element_class_for?(node, **) node.name == 'body' end |
.short_type ⇒ Symbol
Returns the short type
22 23 24 |
# File 'lib/kitchen/book_element.rb', line 22 def self.short_type :book end |
Instance Method Details
#body ⇒ Element
Returns the “body” element
30 31 32 |
# File 'lib/kitchen/book_element.rb', line 30 def body first!('body') end |
#metadata ⇒ MetadataElement
Returns the top metadata element
38 39 40 |
# File 'lib/kitchen/book_element.rb', line 38 def .first end |
#toc ⇒ Element
Returns the table of contents (toc) element
46 47 48 |
# File 'lib/kitchen/book_element.rb', line 46 def toc first!('nav#toc') end |