Sha256: 04b59d4aad032a7d370b286b184fb1ca3d4440dd406f31463273dd60a3d12efd

Contents?: true

Size: 634 Bytes

Versions: 54

Compression:

Stored size: 634 Bytes

Contents

module Parser
  module Source

    ##
    # @api private
    #
    class Rewriter::Action
      attr_reader :range, :replacement

      def initialize(range, replacement='')
        @range, @replacement = range, replacement

        freeze
      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

54 entries across 54 versions & 2 rubygems

Version Path
parser-2.3.0.6 lib/parser/source/rewriter/action.rb
parser-2.3.0.5 lib/parser/source/rewriter/action.rb
parser-2.3.0.4 lib/parser/source/rewriter/action.rb
parser-2.3.0.3 lib/parser/source/rewriter/action.rb
parser-2.3.0.2 lib/parser/source/rewriter/action.rb
parser-2.3.0.1 lib/parser/source/rewriter/action.rb
parser-2.3.0.0 lib/parser/source/rewriter/action.rb
parser-2.3.0.pre.6 lib/parser/source/rewriter/action.rb
parser-2.3.0.pre.5 lib/parser/source/rewriter/action.rb
parser-2.3.0.pre.4 lib/parser/source/rewriter/action.rb
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/parser-2.2.0.pre.4/lib/parser/source/rewriter/action.rb
parser-2.3.0.pre.3 lib/parser/source/rewriter/action.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/parser-2.2.0.pre.4/lib/parser/source/rewriter/action.rb
parser-2.2.3.0 lib/parser/source/rewriter/action.rb
parser-2.2.2.6 lib/parser/source/rewriter/action.rb
parser-2.3.0.pre.2 lib/parser/source/rewriter/action.rb
parser-2.3.0.pre.1 lib/parser/source/rewriter/action.rb
parser-2.2.2.5 lib/parser/source/rewriter/action.rb
parser-2.2.2.3 lib/parser/source/rewriter/action.rb
parser-2.2.2.2 lib/parser/source/rewriter/action.rb