Class: Kitchen::CompositePageElement

Inherits:
ElementBase show all
Defined in:
lib/kitchen/composite_page_element.rb

Overview

An element for a composite page

Instance Attribute Summary

Attributes inherited from ElementBase

#ancestors, #document, #enumerator_class, #search_query_that_found_me, #short_type

Class Method Summary collapse

Instance Method Summary collapse

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?, is_the_element_class_for?, #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

#block_error_if

Constructor Details

#initialize(node:, document: nil) ⇒ CompositePageElement

Creates a new CompositePageElement

Parameters:



13
14
15
16
17
# File 'lib/kitchen/composite_page_element.rb', line 13

def initialize(node:, document: nil)
  super(node: node,
        document: document,
        enumerator_class: CompositePageElementEnumerator)
end

Class Method Details

.short_typeSymbol

Returns the short type

Returns:

  • (Symbol)


22
23
24
# File 'lib/kitchen/composite_page_element.rb', line 22

def self.short_type
  :composite_page
end

Instance Method Details

#is_citation_reference?Boolean

Returns true if this page is a book citation reference

Returns:

  • (Boolean)


65
66
67
# File 'lib/kitchen/composite_page_element.rb', line 65

def is_citation_reference?
  has_class?('os-eob os-reference-container')
end

#is_index?Boolean

Returns true if this page is a book index

Returns:

  • (Boolean)


40
41
42
# File 'lib/kitchen/composite_page_element.rb', line 40

def is_index?
  has_class?('os-index-container')
end

#is_index_of_type?Boolean

Returns true if this page is a book index of type

Returns:

  • (Boolean)


48
49
50
# File 'lib/kitchen/composite_page_element.rb', line 48

def is_index_of_type?
  (self[:class] || '').match?(/os-index-.+-container/)
end

#is_section_reference?Boolean

Returns true if this page is a book section reference

Returns:

  • (Boolean)


73
74
75
# File 'lib/kitchen/composite_page_element.rb', line 73

def is_section_reference?
  has_class?('os-eob os-references-container')
end

#titleElement

Returns the title element (the one in the immediate children, not the one in the metadata)

Returns:

Raises:



31
32
33
34
# File 'lib/kitchen/composite_page_element.rb', line 31

def title
  first!('h3[data-type="title"], h2[data-type="document-title"],' \
         'h1[data-type="document-title"]')
end