Class: AnnotateRb::ModelAnnotator::AnnotatedFile::Updater
- Inherits:
-
Object
- Object
- AnnotateRb::ModelAnnotator::AnnotatedFile::Updater
- Defined in:
- lib/annotate_rb/model_annotator/annotated_file/updater.rb
Overview
Updates existing annotations
Instance Method Summary collapse
-
#initialize(file_content, new_annotations, _annotation_position, parsed_file, options) ⇒ Updater
constructor
A new instance of Updater.
-
#update ⇒ String
Returns the annotated file content to be written back to a file.
Constructor Details
#initialize(file_content, new_annotations, _annotation_position, parsed_file, options) ⇒ Updater
Returns a new instance of Updater.
8 9 10 11 12 13 14 15 |
# File 'lib/annotate_rb/model_annotator/annotated_file/updater.rb', line 8 def initialize(file_content, new_annotations, _annotation_position, parsed_file, ) @options = @new_annotations = new_annotations @file_content = file_content @parsed_file = parsed_file end |
Instance Method Details
#update ⇒ String
Returns the annotated file content to be written back to a file
18 19 20 21 22 23 24 |
# File 'lib/annotate_rb/model_annotator/annotated_file/updater.rb', line 18 def update return "" if !@parsed_file.has_annotations? new_annotation = wrapped_content(@new_annotations) _content = @file_content.sub(@parsed_file.annotations) { new_annotation } end |