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.



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

def initialize(dir)
  super
  @dir = dir
end

Instance Method Details

#do(src) ⇒ Object



17
18
19
# File 'lib/renamr/prepend_date.rb', line 17

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

#set(src) ⇒ Object



21
22
23
# File 'lib/renamr/prepend_date.rb', line 21

def set(src)
  @src = src
end