Class: File
- Inherits:
-
Object
- Object
- File
- Defined in:
- lib/tankobon/ext/file.rb
Class Method Summary collapse
- .archive?(file) ⇒ Boolean
- .archive_extensions ⇒ Object
- .bubble_mv(root_dir, file) ⇒ Object
- .image?(file) ⇒ Boolean
- .image_extensions ⇒ Object
- .rnbase(file, new_name) ⇒ Object
- .splitbase(file) ⇒ Object
- .xform(file_name, &block) ⇒ Object
Class Method Details
.archive?(file) ⇒ Boolean
35 36 37 |
# File 'lib/tankobon/ext/file.rb', line 35 def self.archive?(file) archive_extensions.include? File.extname(file).tail end |
.archive_extensions ⇒ Object
39 40 41 |
# File 'lib/tankobon/ext/file.rb', line 39 def self.archive_extensions ['zip', 'rar', 'cbz', 'cbr'] end |
.bubble_mv(root_dir, file) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/tankobon/ext/file.rb', line 8 def self.bubble_mv(root_dir, file) return if root_dir.eql? File.dirname(file) new_name = "#{File.basename(File.dirname(file))}-#{File.basename(file)}" new_full_name = File.join( File.dirname(File.dirname(file)), new_name) File.rename(file, new_full_name) self.bubble_mv(root_dir, new_full_name) end |
.image?(file) ⇒ Boolean
27 28 29 |
# File 'lib/tankobon/ext/file.rb', line 27 def self.image?(file) image_extensions.include? File.extname(file).tail end |
.image_extensions ⇒ Object
31 32 33 |
# File 'lib/tankobon/ext/file.rb', line 31 def self.image_extensions ['jpg', 'jpeg', 'png', 'gif'] end |
.rnbase(file, new_name) ⇒ Object
18 19 20 21 |
# File 'lib/tankobon/ext/file.rb', line 18 def self.rnbase(file, new_name) File.rename(file, File.join(File.dirname(file), "#{new_name}#{File.extname(file)}")) end |