Class: Renamr::TrimAction
Overview
Collapses consecutive hyphens and removes hyphens next to dots and at the edges.
Instance Method Summary collapse
Methods inherited from Action
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 |