Class: Spoom::Source::Delete
Instance Attribute Summary collapse
- #from ⇒ Object readonly
- #to ⇒ Object readonly
Instance Method Summary collapse
- #apply(bytes) ⇒ Object
-
#initialize(from, to) ⇒ Delete
constructor
A new instance of Delete.
- #range ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(from, to) ⇒ Delete
Returns a new instance of Delete.
119 120 121 122 123 124 |
# File 'lib/spoom/source/rewriter.rb', line 119 def initialize(from, to) super() @from = from @to = to end |
Instance Attribute Details
#from ⇒ Object (readonly)
116 117 118 |
# File 'lib/spoom/source/rewriter.rb', line 116 def from @from end |
#to ⇒ Object (readonly)
116 117 118 |
# File 'lib/spoom/source/rewriter.rb', line 116 def to @to end |
Instance Method Details
#apply(bytes) ⇒ Object
128 129 130 131 132 133 |
# File 'lib/spoom/source/rewriter.rb', line 128 def apply(bytes) raise PositionError, "Position is out of bounds" if from < 0 || to < 0 || from > bytes.size || to > bytes.size || from > to bytes[from..to] = "".bytes end |
#range ⇒ Object
137 138 139 |
# File 'lib/spoom/source/rewriter.rb', line 137 def range [from, to] end |
#to_s ⇒ Object
143 144 145 |
# File 'lib/spoom/source/rewriter.rb', line 143 def to_s "Delete #{from}-#{to}" end |