Module: Six::Renamer
- Defined in:
- lib/six/renamer.rb
Class Method Summary collapse
- .handle_downcase(entry) ⇒ Object
- .handle_downcase_f(entry) ⇒ Object
- .rename(entry, new = nil) ⇒ Object
Class Method Details
.handle_downcase(entry) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/six/renamer.rb', line 12 def handle_downcase(entry) # First handle all entries in directory if File.directory?(entry) Dir[File.join(entry, "*")].each do |e| handle_downcase(e) end end # Rename the current item last rename(entry) end |
.handle_downcase_f(entry) ⇒ Object
24 25 26 27 28 |
# File 'lib/six/renamer.rb', line 24 def handle_downcase_f(entry) Dir[File.join(entry, "*")].each do |e| handle_downcase(e) end end |
.rename(entry, new = nil) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/six/renamer.rb', line 5 def rename(entry, new = nil) tmp = "#{entry}tmp" new = File.join(File.dirname(entry), File.basename(entry).downcase) if new.nil? FileUtils.mv(entry, tmp) FileUtils.mv(tmp, new) end |