class Kitchen::ChapterElement

An element for a chapter

Public Class Methods

new(node:, document: nil) click to toggle source

Creates a new ChapterElement

@param node [Nokogiri::XML::Node] the node this element wraps @param document [Document] this element's document

Calls superclass method
# File lib/kitchen/chapter_element.rb, line 13
def initialize(node:, document: nil)
  super(node: node,
        document: document,
        enumerator_class: ChapterElementEnumerator)
end
short_type() click to toggle source

Returns the short type @return [Symbol]

# File lib/kitchen/chapter_element.rb, line 22
def self.short_type
  :chapter
end

Public Instance Methods

abstracts() click to toggle source

Returns an enumerator for the abstracts

@return [ElementEnumerator]

# File lib/kitchen/chapter_element.rb, line 67
def abstracts
  search('div[data-type="abstract"]')
end
glossaries() click to toggle source

Returns an enumerator for the glossaries

@return [ElementEnumerator]

# File lib/kitchen/chapter_element.rb, line 59
def glossaries
  search("div[data-type='glossary']")
end
has_introduction?() click to toggle source

Returns true if the chapter has an introduction

@return [Boolean]

# File lib/kitchen/chapter_element.rb, line 51
def has_introduction?
  @has_introduction ||= introduction_page.present?
end
introduction_page() click to toggle source

Returns the introduction page

@return [Element, nil]

# File lib/kitchen/chapter_element.rb, line 43
def introduction_page
  pages('$.introduction').first
end
title() click to toggle source

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

@raise [ElementNotFoundError] if no matching element is found @return [Element]

# File lib/kitchen/chapter_element.rb, line 31
def title
  # Get the title in the immediate children, not the one in the metadata.  Could use
  # CSS of ":not([data-type='metadata']) >
  #       [data-type='document-title'], [data-type='document-title']"
  # but xpath is shorter
  first!("./*[@data-type = 'document-title']")
end