Class: WhoAmI::Function::RemoveAnnotation

Inherits:
Object
  • Object
show all
Defined in:
lib/who_am_i/function/remove_annotation.rb

Instance Method Summary collapse

Instance Method Details

#call(file_contents) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/who_am_i/function/remove_annotation.rb', line 4

def call(file_contents)
  if file_contents !~ /\A# == Schema Info/
    return file_contents
  end

  keep_the_rest = false

  kept_lines =
    file_contents.lines.keep_if do |line|
      if keep_the_rest
        next true
      elsif line[0] == "#"
        next false
      else
        keep_the_rest = true
        next false
      end
    end

  kept_lines.join("")
end