Class: Renamr::SubstituteAction
- Defined in:
- lib/renamr/substitute.rb
Overview
Substitutes a string with a string.
Instance Method Summary collapse
- #do(src) ⇒ Object
-
#initialize(src, dst) ⇒ SubstituteAction
constructor
A new instance of SubstituteAction.
Methods inherited from Action
Constructor Details
#initialize(src, dst) ⇒ SubstituteAction
Returns a new instance of SubstituteAction.
12 13 14 15 16 17 18 19 |
# File 'lib/renamr/substitute.rb', line 12 def initialize(src, dst) super raise 'src cannot be nil.' if src.nil? # The action works after PointAction. All points are replaces with minus. @src = p2m(src) @dst = dst.nil? ? '-' : p2m(dst) end |
Instance Method Details
#do(src) ⇒ Object
21 22 23 |
# File 'lib/renamr/substitute.rb', line 21 def do(src) src.gsub(@src, @dst) end |