Class: Spoom::Source::Delete
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
: Integer.
-
#to ⇒ Object
readonly
: Integer.
Instance Method Summary collapse
-
#apply(bytes) ⇒ Object
: (Array) -> void.
-
#initialize(from, to) ⇒ Delete
constructor
: (Integer, Integer) -> void.
-
#range ⇒ Object
: -> [Integer, Integer].
-
#to_s ⇒ Object
: -> String.
Constructor Details
#initialize(from, to) ⇒ Delete
: (Integer, Integer) -> void
118 119 120 121 122 123 |
# File 'lib/spoom/source/rewriter.rb', line 118 def initialize(from, to) super() @from = from @to = to end |
Instance Attribute Details
#from ⇒ Object (readonly)
: Integer
115 116 117 |
# File 'lib/spoom/source/rewriter.rb', line 115 def from @from end |
#to ⇒ Object (readonly)
: Integer
115 116 117 |
# File 'lib/spoom/source/rewriter.rb', line 115 def to @to end |
Instance Method Details
#apply(bytes) ⇒ Object
: (Array) -> void
127 128 129 130 131 |
# File 'lib/spoom/source/rewriter.rb', line 127 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
: -> [Integer, Integer]
135 136 137 |
# File 'lib/spoom/source/rewriter.rb', line 135 def range [from, to] end |
#to_s ⇒ Object
: -> String
141 142 143 |
# File 'lib/spoom/source/rewriter.rb', line 141 def to_s "Delete #{from}-#{to}" end |