Class: GallerySync::Album
- Inherits:
-
Object
- Object
- GallerySync::Album
- Defined in:
- lib/gallery_sync/gallery_sync.rb
Instance Attribute Summary collapse
-
#album_photo ⇒ Object
Returns the value of attribute album_photo.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#photos ⇒ Object
Returns the value of attribute photos.
Instance Method Summary collapse
- #[](photo_name) ⇒ Object
- #get_merge_actions(dest_album) ⇒ Object
-
#initialize(name) ⇒ Album
constructor
A new instance of Album.
-
#load_metadata_from_yaml(file) ⇒ Object
loads metadata from a yaml string title, date_from, date_to.
- #merge_to(dest_album, dest_gallery) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name) ⇒ Album
Returns a new instance of Album.
143 144 145 |
# File 'lib/gallery_sync/gallery_sync.rb', line 143 def initialize(name) @name = name end |
Instance Attribute Details
#album_photo ⇒ Object
Returns the value of attribute album_photo.
140 141 142 |
# File 'lib/gallery_sync/gallery_sync.rb', line 140 def album_photo @album_photo end |
#metadata ⇒ Object
Returns the value of attribute metadata.
140 141 142 |
# File 'lib/gallery_sync/gallery_sync.rb', line 140 def @metadata end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
141 142 143 |
# File 'lib/gallery_sync/gallery_sync.rb', line 141 def name @name end |
#photos ⇒ Object
Returns the value of attribute photos.
140 141 142 |
# File 'lib/gallery_sync/gallery_sync.rb', line 140 def photos @photos end |
Instance Method Details
#[](photo_name) ⇒ Object
194 195 196 197 |
# File 'lib/gallery_sync/gallery_sync.rb', line 194 def [](photo_name) r = photos.select { |p| p.name == photo_name } r.empty? ? nil : r.first end |
#get_merge_actions(dest_album) ⇒ Object
161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/gallery_sync/gallery_sync.rb', line 161 def get_merge_actions(dest_album) r = {} src_album = self src_names = @photos.collect(&:name) dest_names = dest_album.photos.collect(&:name) to_add = src_names - dest_names to_delete = dest_names - src_names r[:add] = to_add.map { |name| src_album[name] } r[:delete] = to_delete.map { |name| dest_album[name] } return r end |
#load_metadata_from_yaml(file) ⇒ Object
loads metadata from a yaml string title, date_from, date_to
156 157 158 159 |
# File 'lib/gallery_sync/gallery_sync.rb', line 156 def (file) @metadata = {} @metadata = YAML::load(file) end |
#merge_to(dest_album, dest_gallery) ⇒ Object
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/gallery_sync/gallery_sync.rb', line 175 def merge_to(dest_album,dest_gallery) merge_actions = get_merge_actions(dest_album) # perform delete merge_actions[:delete].each { |p| dest_gallery.rm_photo p } # perform add merge_actions[:add].each { |p| dest_gallery.upload_photo(p) } # sync metadata if(self. != dest_album.) dest_gallery.(dest_album,self.) end end |
#to_s ⇒ Object
199 200 201 |
# File 'lib/gallery_sync/gallery_sync.rb', line 199 def to_s @name end |