Method: Parser::Source::TreeRewriter#process
- Defined in:
- lib/parser/source/tree_rewriter.rb
#process ⇒ String
Applies all scheduled changes to the source_buffer
and returns
modified source as a new string.
252 253 254 255 256 257 258 259 260 261 262 263 |
# File 'lib/parser/source/tree_rewriter.rb', line 252 def process source = @source_buffer.source chunks = [] last_end = 0 @action_root.ordered_replacements.each do |range, replacement| chunks << source[last_end...range.begin_pos] << replacement last_end = range.end_pos end chunks << source[last_end...source.length] chunks.join end |