Class: Coradoc::Reference::Presentation::SplitPages
- Defined in:
- lib/coradoc/reference/presentation/split_pages.rb
Overview
Instance Attribute Summary collapse
-
#split_at ⇒ Object
readonly
Returns the value of attribute split_at.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(split_at: :section) ⇒ SplitPages
constructor
A new instance of SplitPages.
- #layout(resolved_graph) ⇒ Object
- #locate_page(_edge, target_content, pages:) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(split_at: :section) ⇒ SplitPages
Returns a new instance of SplitPages.
19 20 21 22 23 |
# File 'lib/coradoc/reference/presentation/split_pages.rb', line 19 def initialize(split_at: :section) super() @split_at = split_at.to_sym @page_index = nil end |
Instance Attribute Details
#split_at ⇒ Object (readonly)
Returns the value of attribute split_at.
13 14 15 |
# File 'lib/coradoc/reference/presentation/split_pages.rb', line 13 def split_at @split_at end |
Class Method Details
.key ⇒ Object
15 16 17 |
# File 'lib/coradoc/reference/presentation/split_pages.rb', line 15 def self.key :split_pages end |
Instance Method Details
#layout(resolved_graph) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/coradoc/reference/presentation/split_pages.rb', line 25 def layout(resolved_graph) children = read_children(resolved_graph) return [single_page_for(resolved_graph)] if children.nil? || children.empty? sections = children.select { |child| matches_split?(child) } return [single_page_for(resolved_graph)] if sections.empty? pages = sections.map.with_index { |section, idx| page_for(section, resolved_graph, idx) } index_pages!(pages) pages end |
#locate_page(_edge, target_content, pages:) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/coradoc/reference/presentation/split_pages.rb', line 37 def locate_page(_edge, target_content, pages:) indexed = @page_index&.[](target_content) return indexed if indexed pages.find { |page| owns_target?(page, target_content) } end |