Class: PicasaDownloader::AlbumPersister

Inherits:
Object
  • Object
show all
Defined in:
lib/picasa-downloader/album_persister.rb

Instance Method Summary collapse

Constructor Details

#initialize(client, album, download_directory_root) ⇒ AlbumPersister

Returns a new instance of AlbumPersister.



3
4
5
6
7
# File 'lib/picasa-downloader/album_persister.rb', line 3

def initialize(client, album, download_directory_root)
  @client = client
  @album = album
  @download_directory_root = download_directory_root
end

Instance Method Details

#downloadObject



9
10
11
12
13
14
# File 'lib/picasa-downloader/album_persister.rb', line 9

def download
  FileUtils.mkdir_p(get_temp_album_dir)
  photos = @client.list_photos(@album.id)
  download_and_persist_to_disk(photos)
  move_to_final_dir(photos)
end

#persist_to_disk(photo, photo_data) ⇒ Object



19
20
21
22
23
24
# File 'lib/picasa-downloader/album_persister.rb', line 19

def persist_to_disk(photo, photo_data)
  File.open(get_temp_album_dir + photo.name, 'wb') { |file|
    file.write(photo_data)
    FileUtils.touch(file.path, :mtime => photo.created_date)
  }
end