Sha256: 8fea47d2301ed0cade86a4e2e48bcc25de347c838e5d4e258679e1b39abde1c9
Contents?: true
Size: 1.69 KB
Versions: 3
Compression:
Stored size: 1.69 KB
Contents
# frozen_string_literal: true module Kitchen # An element for a chapter # class ChapterElement < ElementBase # Creates a new +ChapterElement+ # # @param node [Nokogiri::XML::Node] the node this element wraps # @param document [Document] this element's document # def initialize(node:, document: nil) super(node: node, document: document, enumerator_class: ChapterElementEnumerator) end # Returns the short type # @return [Symbol] # def self.short_type :chapter end # 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] # 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 # Returns the introduction page # # @return [Element, nil] # def introduction_page pages('$.introduction').first end # Returns true if the chapter has an introduction # # @return [Boolean] # def has_introduction? @has_introduction ||= introduction_page.present? end # Returns an enumerator for the glossaries # # @return [ElementEnumerator] # def glossaries search("div[data-type='glossary']") end # Returns an enumerator for the abstracts # # @return [ElementEnumerator] # def abstracts search('div[data-type="abstract"]') end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
openstax_kitchen-11.2.0 | lib/kitchen/chapter_element.rb |
openstax_kitchen-11.1.0 | lib/kitchen/chapter_element.rb |
openstax_kitchen-11.0.0 | lib/kitchen/chapter_element.rb |