Class: SeeingIsBelieving::Binary::RemoveAnnotations
- Inherits:
-
Object
- Object
- SeeingIsBelieving::Binary::RemoveAnnotations
- Defined in:
- lib/seeing_is_believing/binary/remove_annotations.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(raw_code, remove_value_prefixes, markers) ⇒ RemoveAnnotations
constructor
A new instance of RemoveAnnotations.
Constructor Details
#initialize(raw_code, remove_value_prefixes, markers) ⇒ RemoveAnnotations
Returns a new instance of RemoveAnnotations.
11 12 13 14 15 16 |
# File 'lib/seeing_is_believing/binary/remove_annotations.rb', line 11 def initialize(raw_code, remove_value_prefixes, markers) self.remove_value_prefixes = remove_value_prefixes self.raw_code = raw_code self.markers = markers self.code = Code.new(raw_code, 'strip_comments') end |
Class Method Details
.call(raw_code, remove_value_prefixes, markers) ⇒ Object
7 8 9 |
# File 'lib/seeing_is_believing/binary/remove_annotations.rb', line 7 def self.call(raw_code, remove_value_prefixes, markers) new(raw_code, remove_value_prefixes, markers).call end |
Instance Method Details
#call ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/seeing_is_believing/binary/remove_annotations.rb', line 18 def call annotation_chunks_in(code).each do |comment, rest| rest.each { |comment| code.rewriter.remove comment.comment_range remove_whitespace_before comment.comment_range.begin_pos, code.buffer, code.rewriter, false } case comment.text when value_regex if remove_value_prefixes code.rewriter.remove comment.comment_range remove_whitespace_before comment.comment_range.begin_pos, code.buffer, code.rewriter, false else prefix = comment.text[value_regex].rstrip code.rewriter.replace comment.comment_range, prefix end when exception_regex code.rewriter.remove comment.comment_range remove_whitespace_before comment.comment_range.begin_pos, code.buffer, code.rewriter, true when stdout_regex code.rewriter.remove comment.comment_range remove_whitespace_before comment.comment_range.begin_pos, code.buffer, code.rewriter, true when stderr_regex code.rewriter.remove comment.comment_range remove_whitespace_before comment.comment_range.begin_pos, code.buffer, code.rewriter, true else raise "This should be impossible! Something must be broken in the comment section above" end end code.rewriter.process end |