Class: Uniword::FindReplace::Scope
- Inherits:
-
Object
- Object
- Uniword::FindReplace::Scope
- Defined in:
- lib/uniword/find_replace/scope.rb
Overview
Abstract scope: knows how to enumerate text-bearing nodes in one part of the package and run a matcher over them.
Each subclass implements each_text_node, yielding
[holder, accessor] pairs where holder is the object whose
text we read/write and accessor is a TextAccessor value
object with value and value= methods.
Open/closed: a new scope = a new subclass + registration in
Engine::SCOPE_REGISTRY. Engine and other scopes are
unchanged.
Direct Known Subclasses
BodyScope, CommentScope, EndnoteScope, FooterScope, FootnoteScope, HeaderScope, StylesScope
Defined Under Namespace
Classes: TextAccessor
Instance Method Summary collapse
-
#each_text_node {|holder, accessor| ... } ⇒ void
Yield
[holder, accessor]for every text node this scope covers. -
#initialize(document) ⇒ Scope
constructor
A new instance of Scope.
-
#name ⇒ Symbol
Scope name (e.g. :body, :headers).
Constructor Details
#initialize(document) ⇒ Scope
Returns a new instance of Scope.
18 19 20 |
# File 'lib/uniword/find_replace/scope.rb', line 18 def initialize(document) @document = document end |
Instance Method Details
#each_text_node {|holder, accessor| ... } ⇒ void
This method returns an undefined value.
Yield [holder, accessor] for every text node this scope
covers. Engine applies the matcher to each accessor.
34 35 36 |
# File 'lib/uniword/find_replace/scope.rb', line 34 def each_text_node raise NotImplementedError end |
#name ⇒ Symbol
Returns scope name (e.g. :body, :headers).
23 24 25 |
# File 'lib/uniword/find_replace/scope.rb', line 23 def name raise NotImplementedError end |