Class: RBS::Inline::Annotator::Writer::Replace

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



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/rbs/inline/annotator/writer.rb', line 48

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