Class: Coradoc::Reference::Resolution::ReplaceWalker

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

Overview

Rebuilds the tree, replacing every Edge-bearing node with the materializer's output. The walker is single-purpose and only lives inside Resolution — no need for a separate file.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pages:, results:, presentation:, registry:, missing_policy:, format:) ⇒ ReplaceWalker

Returns a new instance of ReplaceWalker.



96
97
98
99
100
101
102
103
104
# File 'lib/coradoc/reference/resolution.rb', line 96

def initialize(pages:, results:, presentation:, registry:,
               missing_policy:, format:)
  @pages = pages
  @results = results
  @presentation = presentation
  @registry = registry
  @missing_policy = missing_policy
  @format = format
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



93
94
95
# File 'lib/coradoc/reference/resolution.rb', line 93

def format
  @format
end

#missing_policyObject (readonly)

Returns the value of attribute missing_policy.



93
94
95
# File 'lib/coradoc/reference/resolution.rb', line 93

def missing_policy
  @missing_policy
end

#pagesObject (readonly)

Returns the value of attribute pages.



93
94
95
# File 'lib/coradoc/reference/resolution.rb', line 93

def pages
  @pages
end

#presentationObject (readonly)

Returns the value of attribute presentation.



93
94
95
# File 'lib/coradoc/reference/resolution.rb', line 93

def presentation
  @presentation
end

#registryObject (readonly)

Returns the value of attribute registry.



93
94
95
# File 'lib/coradoc/reference/resolution.rb', line 93

def registry
  @registry
end

#resultsObject (readonly)

Returns the value of attribute results.



93
94
95
# File 'lib/coradoc/reference/resolution.rb', line 93

def results
  @results
end

Instance Method Details

#visit(node) ⇒ Object



106
107
108
109
110
111
112
113
# File 'lib/coradoc/reference/resolution.rb', line 106

def visit(node)
  return node unless node.is_a?(Coradoc::CoreModel::Base)

  replaced = replace_node(node)
  return replaced unless replaced.is_a?(Coradoc::CoreModel::HasChildren)

  rebuild_children_of(replaced)
end