Sha256: f3a25673aff993d2322d2e3ad32089348a1b28d88fba12d36f2641c9b906c01f
Contents?: true
Size: 1.41 KB
Versions: 3
Compression:
Stored size: 1.41 KB
Contents
# frozen_string_literal: true module Kitchen # An element for a composite page # class CompositePageElement < ElementBase # Creates a new +CompositePageElement+ # # @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: CompositePageElementEnumerator, short_type: :composite_page) 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 true if this class represents the element for the given node # # @param node [Nokogiri::XML::Node] the underlying node # @return [Boolean] # def self.is_the_element_class_for?(node) node['data-type'] == 'composite-page' end # Returns true if this page is a book index # # @return [Boolean] # def is_index? has_class?('os-index-container') end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
openstax_kitchen-3.2.0 | lib/kitchen/composite_page_element.rb |
openstax_kitchen-3.1.0 | lib/kitchen/composite_page_element.rb |
openstax_kitchen-3.0.0 | lib/kitchen/composite_page_element.rb |