Class: Coradoc::Reference::Presentation::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/coradoc/reference/presentation/base.rb

Overview

Protocol base. Subclasses implement #layout (resolved graph → Pages) and #locate_page (find which page a target lives on).

A Presentation NEVER reads the original document — it consumes the resolved graph produced by the Resolver. It never renders.

Direct Known Subclasses

CustomHierarchy, SingleDocument, SplitPages

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.keyObject

Registry key used in materializer lookup tuples [kind, presentation, format]. Subclasses override so materializers can target a specific layout.



15
16
17
# File 'lib/coradoc/reference/presentation/base.rb', line 15

def self.key
  :any
end

Instance Method Details

#keyObject



19
20
21
# File 'lib/coradoc/reference/presentation/base.rb', line 19

def key
  self.class.key
end

#layout(resolved_graph) ⇒ Array<Page>

Lay out the resolved graph as a tree of Pages. Subclasses decide slicing, ordering, hierarchy.

Parameters:

  • resolved_graph (CoreModel::Base)

    the document the caller wants to present. Already resolved (edges → targets).

Returns:

Raises:

  • (NotImplementedError)


29
30
31
# File 'lib/coradoc/reference/presentation/base.rb', line 29

def layout(resolved_graph)
  raise NotImplementedError
end

#locate_page(edge, target_content, pages:) ⇒ Page?

Given an Edge and its resolved target, find the Page where the target lives. This is what makes cross-references survive re-pagination.

Parameters:

Returns:

Raises:

  • (NotImplementedError)


41
42
43
# File 'lib/coradoc/reference/presentation/base.rb', line 41

def locate_page(edge, target_content, pages:)
  raise NotImplementedError
end