Class: Renamr::TrimAction

Inherits:
Action
  • Object
show all
Defined in:
lib/renamr/trim.rb

Overview

Collapses consecutive hyphens and removes hyphens next to dots and at the edges.

Instance Method Summary collapse

Methods inherited from Action

#p2m, #set

Instance Method Details

#do(src) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/renamr/trim.rb', line 13

def do(src)
  src.squeeze!('-')
  src.gsub!('-.', '.')
  src.gsub!('.-', '.')
  src.gsub!(/^-|-$/, '') unless src == '-'
  src
end