Class: RBS::Inline::Annotator::Writer::InsertAfter

Inherits:
Action
  • Object
show all
Defined in:
lib/rbs/inline/annotator/writer.rb

Instance Attribute Summary

Attributes inherited from Action

#range, #text

Instance Method Summary collapse

Methods inherited from Action

#initialize

Constructor Details

This class inherits a constructor from RBS::Inline::Annotator::Writer::Action

Instance Method Details

#process(writer) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/rbs/inline/annotator/writer.rb', line 34

def process(writer)
  if writer.before_pos < range.end
    writer.slice << writer.source[writer.before_pos...range.end]
    writer.before_pos = range.end
  elsif writer.before_pos == range.end - 1
    # do nothing
  else
    raise "invalid range: #{range}, before_pos: #{writer.before_pos}"
  end
  writer.slice << text
end