Class: Ast::Merge::Detector::Base Abstract
- Inherits:
-
Object
- Object
- Ast::Merge::Detector::Base
- Defined in:
- lib/ast/merge/detector/base.rb
Overview
This class is abstract.
Subclass and implement #region_type and #detect_all
Base class for region detection.
Region detectors identify portions of a document that should be handled
by a specialized merger.
Subclasses must implement:
- #region_type - Returns the type symbol for detected regions
- #detect_all - Finds all regions of this type in a document
Direct Known Subclasses
Instance Method Summary collapse
-
#detect_all(_source) ⇒ Array<Region>
abstract
Detects all regions of this type in the given source.
-
#inspect ⇒ String
-
#name ⇒ String
A human-readable name for this detector.
-
#region_type ⇒ Symbol
abstract
Returns the type symbol for regions detected by this detector.
-
#strip_delimiters? ⇒ Boolean
Whether to strip delimiters from content before passing to merger.
Instance Method Details
#detect_all(_source) ⇒ Array<Region>
This method is abstract.
Detects all regions of this type in the given source.
150 151 152 |
# File 'lib/ast/merge/detector/base.rb', line 150 def detect_all(_source) raise NotImplementedError, "#{self.class}#detect_all must be implemented" end |
#inspect ⇒ String
167 168 169 |
# File 'lib/ast/merge/detector/base.rb', line 167 def inspect "#<#{name} region_type=#{region_type}>" end |
#name ⇒ String
A human-readable name for this detector.
162 163 164 |
# File 'lib/ast/merge/detector/base.rb', line 162 def name self.class.name || "AnonymousDetector" end |
#region_type ⇒ Symbol
This method is abstract.
Returns the type symbol for regions detected by this detector.
142 143 144 |
# File 'lib/ast/merge/detector/base.rb', line 142 def region_type raise NotImplementedError, "#{self.class}#region_type must be implemented" end |
#strip_delimiters? ⇒ Boolean
Whether to strip delimiters from content before passing to merger.
156 157 158 |
# File 'lib/ast/merge/detector/base.rb', line 156 def strip_delimiters? true end |