Class: Pragmater::Processors::Inserter

Inherits:
Object
  • Object
show all
Defined in:
lib/pragmater/processors/inserter.rb

Overview

Inserts new pragma comments.

Instance Method Summary collapse

Constructor Details

#initialize(comments, body) ⇒ Inserter

Returns a new instance of Inserter.



7
8
9
10
# File 'lib/pragmater/processors/inserter.rb', line 7

def initialize comments, body
  @comments = comments
  @body = body
end

Instance Method Details

#callObject



12
13
14
15
16
17
# File 'lib/pragmater/processors/inserter.rb', line 12

def call
  body.first.then do |first|
    comments.append "\n" unless first == "\n" || body.empty?
    comments + body
  end
end