Class: Picturama::Picture
- Inherits:
-
File
- Object
- File
- Picturama::Picture
- Defined in:
- lib/picturama/picture.rb
Instance Attribute Summary collapse
-
#metainfo ⇒ Object
Returns the value of attribute metainfo.
-
#resized ⇒ Object
Returns the value of attribute resized.
-
#thumbnail ⇒ Object
Returns the value of attribute thumbnail.
Instance Method Summary collapse
- #basename ⇒ Object
- #has_resized? ⇒ Boolean
- #has_thumbnail? ⇒ Boolean
- #info ⇒ Object
-
#initialize(args) ⇒ Picture
constructor
A new instance of Picture.
- #remove_assoc ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(args) ⇒ Picture
Returns a new instance of Picture.
8 9 10 11 12 13 |
# File 'lib/picturama/picture.rb', line 8 def initialize(args) super @thumbnail = "#{File.dirname(path)}/thumbnails/#{Picturama::config['thumbnail_prefix']}#{basename}" @resized = "#{File.dirname(path)}/resized/resized_#{basename}" @metainfo = "#{File.dirname(path)}/resized/resized_#{basename}.info" end |
Instance Attribute Details
#metainfo ⇒ Object
Returns the value of attribute metainfo.
6 7 8 |
# File 'lib/picturama/picture.rb', line 6 def @metainfo end |
#resized ⇒ Object
Returns the value of attribute resized.
6 7 8 |
# File 'lib/picturama/picture.rb', line 6 def resized @resized end |
#thumbnail ⇒ Object
Returns the value of attribute thumbnail.
6 7 8 |
# File 'lib/picturama/picture.rb', line 6 def thumbnail @thumbnail end |
Instance Method Details
#basename ⇒ Object
15 16 17 |
# File 'lib/picturama/picture.rb', line 15 def basename File.basename(path) end |
#has_resized? ⇒ Boolean
23 24 25 |
# File 'lib/picturama/picture.rb', line 23 def has_resized? File.exists?(@resized) end |
#has_thumbnail? ⇒ Boolean
27 28 29 |
# File 'lib/picturama/picture.rb', line 27 def has_thumbnail? File.exists?(@thumbnail) && File.size(@thumbnail) < size end |
#info ⇒ Object
19 20 21 |
# File 'lib/picturama/picture.rb', line 19 def info File.read(@metainfo) if File.exists?(@metainfo) end |
#remove_assoc ⇒ Object
31 32 33 34 |
# File 'lib/picturama/picture.rb', line 31 def remove_assoc File.delete(@thumbnail) if has_thumbnail? File.delete(@resized) if has_resized? end |
#type ⇒ Object
36 37 38 |
# File 'lib/picturama/picture.rb', line 36 def type File.extname(path).split('.').last end |