Class: PhotoHandler::Photo
- Inherits:
-
Object
- Object
- PhotoHandler::Photo
- Defined in:
- lib/photo_handler/photo.rb
Instance Method Summary collapse
- #destination_file_name ⇒ Object
- #exif ⇒ Object
-
#initialize(filename) ⇒ Photo
constructor
A new instance of Photo.
Constructor Details
#initialize(filename) ⇒ Photo
Returns a new instance of Photo.
5 6 7 8 |
# File 'lib/photo_handler/photo.rb', line 5 def initialize(filename) @filename = filename self end |
Instance Method Details
#destination_file_name ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/photo_handler/photo.rb', line 21 def destination_file_name elements = Config.destination_file_name.split("/") elements.map! do |element| case element when ":ext" File.extname(@filename).downcase[1..-1] when ":date" exif.date_time.strftime("%Y-%m-%d") when ":original_name" File.basename(@filename) else element end end File.join(elements) end |
#exif ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/photo_handler/photo.rb', line 10 def exif unless @exif begin @exif = EXIFR::JPEG.new(@filename) rescue EXIFR::MalformedJPEG @exif = EXIFR::TIFF.new(@filename) end end @exif end |