Class: Roto
- Inherits:
-
Object
- Object
- Roto
- Defined in:
- lib/roto.rb
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#types ⇒ Object
Returns the value of attribute types.
Instance Method Summary collapse
- #copy_files(destination) ⇒ Object
- #find_files(path) ⇒ Object
-
#initialize ⇒ Roto
constructor
A new instance of Roto.
- #move_files(destination) ⇒ Object
Constructor Details
#initialize ⇒ Roto
Returns a new instance of Roto.
8 9 10 11 |
# File 'lib/roto.rb', line 8 def initialize @files = [] @types = ['.mp4', '.jpg', '.png'] end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
6 7 8 |
# File 'lib/roto.rb', line 6 def files @files end |
#types ⇒ Object
Returns the value of attribute types.
7 8 9 |
# File 'lib/roto.rb', line 7 def types @types end |
Instance Method Details
#copy_files(destination) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/roto.rb', line 30 def copy_files(destination) = ProgressBar.create(total: @files.count) @files.each do |file| FileUtils.cp("#{file}", "#{destination}") .increment end end |
#find_files(path) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/roto.rb', line 13 def find_files(path) Find.find(path).each do |file| if @types.include?(File.extname(file).downcase) @files << file puts "collected #{@files.count} files" end end end |
#move_files(destination) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/roto.rb', line 22 def move_files(destination) = ProgressBar.create(total: @files.count) @files.each do |file| FileUtils.mv("#{file}", "#{destination}") .increment end end |