Class: Banzai::ReferenceExtractor
- Inherits:
-
Object
- Object
- Banzai::ReferenceExtractor
show all
- Defined in:
- lib/banzai/reference_extractor.rb
Overview
Extract possible GFM references from an arbitrary String for further processing.
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ReferenceExtractor.
6
7
8
|
# File 'lib/banzai/reference_extractor.rb', line 6
def initialize
@texts_and_contexts = []
end
|
Instance Method Details
#analyze(text, context = {}) ⇒ Object
10
11
12
|
# File 'lib/banzai/reference_extractor.rb', line 10
def analyze(text, context = {})
@texts_and_contexts << { text: text, context: context }
end
|
#references(type, project, current_user, ids_only: false) ⇒ Object
14
15
16
17
18
19
|
# File 'lib/banzai/reference_extractor.rb', line 14
def references(type, project, current_user, ids_only: false)
context = RenderContext.new(project, current_user)
processor = Banzai::ReferenceParser[type].new(context)
processor.process(html_documents, ids_only: ids_only)
end
|
#reset_memoized_values ⇒ Object
21
22
23
24
|
# File 'lib/banzai/reference_extractor.rb', line 21
def reset_memoized_values
@html_documents = nil
@texts_and_contexts = []
end
|