Class: Renamr::RemoveAction
Overview
Removes symbols between left and right positions.
Instance Method Summary collapse
- #do(src) ⇒ Object
-
#initialize(pos, len) ⇒ RemoveAction
constructor
A new instance of RemoveAction.
Methods inherited from Action
Constructor Details
#initialize(pos, len) ⇒ RemoveAction
Returns a new instance of RemoveAction.
12 13 14 15 16 17 18 19 20 |
# File 'lib/renamr/remove.rb', line 12 def initialize(pos, len) super raise 'len cannot bi nil.' if len.nil? raise 'pos cannot be nil.' if pos.nil? raise 'pos has to be positive.' unless pos.to_i.positive? @pos = pos.to_i @len = len.to_i end |
Instance Method Details
#do(src) ⇒ Object
22 23 24 25 26 |
# File 'lib/renamr/remove.rb', line 22 def do(src) return src[@len..] if @pos == 1 src[0..@pos - 1] + src[@pos + @len..] end |