Class: Parser::Source::Rewriter::Action Private
- Inherits:
-
Object
- Object
- Parser::Source::Rewriter::Action
- Includes:
- Comparable
- Defined in:
- lib/parser/source/rewriter/action.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #allow_multiple_insertions ⇒ Object (also: #allow_multiple_insertions?) readonly private
- #order ⇒ Object readonly private
- #range ⇒ Object readonly private
- #replacement ⇒ Object readonly private
Instance Method Summary collapse
- #<=>(other) ⇒ Object private
-
#initialize(range, replacement = '', allow_multiple_insertions = false, order = 0) ⇒ Action
constructor
private
A new instance of Action.
- #to_s ⇒ Object private
Constructor Details
#initialize(range, replacement = '', allow_multiple_insertions = false, order = 0) ⇒ Action
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Action.
15 16 17 18 19 20 21 22 |
# File 'lib/parser/source/rewriter/action.rb', line 15 def initialize(range, replacement='', allow_multiple_insertions = false, order = 0) @range = range @replacement = replacement @allow_multiple_insertions = allow_multiple_insertions @order = order freeze end |
Instance Attribute Details
#allow_multiple_insertions ⇒ Object (readonly) Also known as: allow_multiple_insertions?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 |
# File 'lib/parser/source/rewriter/action.rb', line 12 def allow_multiple_insertions @allow_multiple_insertions end |
#order ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 |
# File 'lib/parser/source/rewriter/action.rb', line 12 def order @order end |
#range ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 |
# File 'lib/parser/source/rewriter/action.rb', line 12 def range @range end |
#replacement ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 |
# File 'lib/parser/source/rewriter/action.rb', line 12 def replacement @replacement end |
Instance Method Details
#<=>(other) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
24 25 26 27 28 |
# File 'lib/parser/source/rewriter/action.rb', line 24 def <=>(other) result = range.begin_pos <=> other.range.begin_pos return result unless result.zero? order <=> other.order end |
#to_s ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/parser/source/rewriter/action.rb', line 30 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 |