Class: Renamr::PrependDateAction

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

Overview

Prepends file modification datestamp.

Instance Method Summary collapse

Methods inherited from Action

#p2m

Constructor Details

#initialize(dir) ⇒ PrependDateAction

Returns a new instance of PrependDateAction.



11
12
13
# File 'lib/renamr/prepend_date.rb', line 11

def initialize(dir)
  @dir = dir
end

Instance Method Details

#do(src) ⇒ Object



15
16
17
# File 'lib/renamr/prepend_date.rb', line 15

def do(src)
  src.prepend(File.mtime(File.join(@dir, @src)).strftime('%Y%m%d-'))
end

#set(src) ⇒ Object



19
20
21
# File 'lib/renamr/prepend_date.rb', line 19

def set(src)
  @src = src
end