Sha256: ea9ca4afbdf251eee8b0777ed5856cf5a82eeb946ae0323a95bf13e34c8a708f
Contents?: true
Size: 1.05 KB
Versions: 22
Compression:
Stored size: 1.05 KB
Contents
module Parser module Source ## # @api private # class Rewriter::Action include Comparable attr_reader :range, :replacement, :allow_multiple_insertions, :order alias_method :allow_multiple_insertions?, :allow_multiple_insertions def initialize(range, replacement='', allow_multiple_insertions = false, order = 0) @range = range @replacement = replacement @allow_multiple_insertions = allow_multiple_insertions @order = order freeze end def <=>(other) result = range.begin_pos <=> other.range.begin_pos return result unless result.zero? order <=> other.order end def to_s if @range.length == 0 && @replacement.empty? 'do nothing' elsif @range.length == 0 "insert #{@replacement.inspect}" elsif @replacement.empty? "remove #{@range.length} character(s)" else "replace #{@range.length} character(s) with #{@replacement.inspect}" end end end end end
Version data entries
22 entries across 22 versions & 4 rubygems