Class: SeeingIsBelieving::Binary::RemovePreviousAnnotations

Inherits:
Object
  • Object
show all
Defined in:
lib/seeing_is_believing/binary/remove_previous_annotations.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code) ⇒ RemovePreviousAnnotations

Returns a new instance of RemovePreviousAnnotations.



10
11
12
13
14
15
16
17
# File 'lib/seeing_is_believing/binary/remove_previous_annotations.rb', line 10

def initialize(code)
  self.code     = code
  self.comments = { result:    [],
                    exception: [],
                    stdout:    [],
                    stderr:    [],
                  }
end

Class Method Details

.call(code) ⇒ Object



6
7
8
# File 'lib/seeing_is_believing/binary/remove_previous_annotations.rb', line 6

def self.call(code)
  new(code).call
end

Instance Method Details

#callObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/seeing_is_believing/binary/remove_previous_annotations.rb', line 19

def call
  RemoveInlineComments.call code, additional_rewrites: remove_whitespace_preceeding_comments do |comment|
    if    comment.text[/\A#\s*=>/] then comments[:result]    << comment; true
    elsif comment.text[/\A#\s*~>/] then comments[:exception] << comment; true
    elsif comment.text[/\A#\s*>>/] then comments[:stdout]    << comment; true
    elsif comment.text[/\A#\s*!>/] then comments[:stderr]    << comment; true
    else                                                                 false
    end
  end
end