Class: EventSplittr::PhotoCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/event_splittr/photo_collection.rb

Instance Method Summary collapse

Constructor Details

#initialize(paths) ⇒ PhotoCollection

Returns a new instance of PhotoCollection.



6
7
8
# File 'lib/event_splittr/photo_collection.rb', line 6

def initialize(paths)
  @photos = paths.select {|path| File.extname(path).downcase == ".jpg"}.map {|path| Photo.new(path)}
end

Instance Method Details

#split(destination_dir) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/event_splittr/photo_collection.rb', line 10

def split(destination_dir)      
  @photos.each do |photo|
    FileUtils.mkdir_p("#{destination_dir}/#{photo.project_name}")
    FileUtils.mv(photo.path, photo.destination_path(destination_dir))
    puts "Moved: #{photo.path} to #{photo.destination_path(destination_dir)}"
  end
  puts "-> Moved #{@photos.size} photos."
end

#split_dry_run(destination_dir) ⇒ Object



19
20
21
22
23
# File 'lib/event_splittr/photo_collection.rb', line 19

def split_dry_run(destination_dir)
  @photos.each do |photo|
    puts "Will move: #{photo.path} to #{photo.destination_path(destination_dir)}"
  end
end