Class: Fleakr::Objects::Set
- Inherits:
-
Object
- Object
- Fleakr::Objects::Set
- Includes:
- Support::Object
- Defined in:
- lib/fleakr/objects/set.rb
Overview
Set
Attributes
- id
-
The ID for this photoset
- title
-
The title of this photoset
- description
-
The description of this set
- count
-
Count of photos in this set
Associations
- photos
-
The collection of photos for this set. See Fleakr::Objects::Photo
- comments
-
All comments associated with this set. See Fleakr::Objects::Comment
Instance Method Summary collapse
-
#file_prefix(index) ⇒ Object
:nodoc:.
-
#save_to(path, size) ⇒ Object
Save all photos in this set to the specified directory for the specified size.
Methods included from Support::Object
Instance Method Details
#file_prefix(index) ⇒ Object
:nodoc:
44 45 46 |
# File 'lib/fleakr/objects/set.rb', line 44 def file_prefix(index) # :nodoc: sprintf("%0#{self.count.length}d_", (index + 1)) end |
#save_to(path, size) ⇒ Object
Save all photos in this set to the specified directory for the specified size. Allowed Sizes include :square
, :small
, :thumbnail
, :medium
,
:large
, and :original
. When saving the set, this method will create a subdirectory based on the set’s title.
34 35 36 37 38 39 40 41 42 |
# File 'lib/fleakr/objects/set.rb', line 34 def save_to(path, size) target = "#{path}/#{self.title}" FileUtils.mkdir(target) unless File.exist?(target) self.photos.each_with_index do |photo, index| image = photo.send(size) image.save_to(target, file_prefix(index)) unless image.nil? end end |