Class: AbsoluteRenamer::DateModule
- Inherits:
-
IModule
- Object
- IModule
- AbsoluteRenamer::DateModule
- Defined in:
- lib/AbsoluteRenamer-date/module.rb
Instance Method Summary collapse
-
#initialize ⇒ DateModule
constructor
A new instance of DateModule.
- #interpret(file, infos, type) ⇒ Object
- #now(infos) ⇒ Object
- #time(file, infos) ⇒ Object
Constructor Details
#initialize ⇒ DateModule
Returns a new instance of DateModule.
3 4 5 6 7 8 9 10 |
# File 'lib/AbsoluteRenamer-date/module.rb', line 3 def initialize @filters = [ pattern("(now)(:(.*))"), pattern("([acm]time)(:(.*))") ] @slash_replacement = conf[:options][:system_slash_replacement] || '-' end |
Instance Method Details
#interpret(file, infos, type) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/AbsoluteRenamer-date/module.rb', line 12 def interpret(file, infos, type) if infos[0].match(/now[:-]/) self.now(infos) elsif infos[0].match(/[acm]time[:-]/) self.time(file, infos) end end |
#now(infos) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/AbsoluteRenamer-date/module.rb', line 20 def now(infos) modifier = infos.delete_at(2) infos.compact! time = Time.now.strftime(infos[4]) modify time, modifier end |
#time(file, infos) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/AbsoluteRenamer-date/module.rb', line 28 def time(file, infos) modifier = infos.delete_at(7) infos.compact! time = File.method(infos[2]).call(file.real_path) time = time.strftime(infos[4]) modify time, modifier end |