Class: PhotoFile
- Inherits:
-
Object
- Object
- PhotoFile
- Defined in:
- lib/ralbum/photo_tree/photo_file.rb
Instance Attribute Summary collapse
-
#geometry ⇒ Object
readonly
Returns the value of attribute geometry.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(path) ⇒ PhotoFile
constructor
A new instance of PhotoFile.
- #md5 ⇒ Object
- #time ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(path) ⇒ PhotoFile
Returns a new instance of PhotoFile.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/ralbum/photo_tree/photo_file.rb', line 9 def initialize( path ) if not File.exist?(path) raise RAlbumException.new "file '#{path}' not exist" end if File.directory?(path) raise RAlbumException.new "expected '#{path}' as file but it is a directory" end read_info(path) end |
Instance Attribute Details
#geometry ⇒ Object (readonly)
Returns the value of attribute geometry.
7 8 9 |
# File 'lib/ralbum/photo_tree/photo_file.rb', line 7 def geometry @geometry end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
6 7 8 |
# File 'lib/ralbum/photo_tree/photo_file.rb', line 6 def height @height end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/ralbum/photo_tree/photo_file.rb', line 3 def path @path end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
4 5 6 |
# File 'lib/ralbum/photo_tree/photo_file.rb', line 4 def size @size end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
5 6 7 |
# File 'lib/ralbum/photo_tree/photo_file.rb', line 5 def width @width end |
Instance Method Details
#md5 ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/ralbum/photo_tree/photo_file.rb', line 25 def md5 return @md5 if @md5 blob = File.open(path, "rb") do |f| f.read end @md5 = MD5.new( blob ).to_s # ralbum_verbose( 2, sprintf("%40s: %d %s \n", name, time, @md5 ) ) end |
#time ⇒ Object
20 21 22 23 |
# File 'lib/ralbum/photo_tree/photo_file.rb', line 20 def time return @time if ! @time.nil? @time = File.mtime( @path ) end |
#to_s ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ralbum/photo_tree/photo_file.rb', line 34 def to_s s = @path + "\n" s << sprintf("%40s: %s \n", "file size", "#{@size} Kb") s << sprintf("%40s: %s \n", "image size", "#{@width} X #{@height}") s << sprintf("%40s: %s \n", "timestamp", "#{@timestamp}") s << sprintf("%40s: %s \n", "exposuretime", "#{@exposuretime} ") s << sprintf("%40s: %s \n", "aperture", "#{@aperture}") s << sprintf("%40s: %s \n", "exposure_bias", "#{@exposure_bias}") s << sprintf("%40s: %s \n", "flash", "#{@flash}") s << sprintf("%40s: %s \n", "focal_length", "#{@focal_length}") s << sprintf("%40s: %s \n", "iso_speed","#{@iso_speed}") s << sprintf("%40s: %s \n", "caption","#{@caption}") s << sprintf("%40s: %s \n", "keywords","#{@keywords}") s << sprintf("%40s: %s \n", "copyright","#{@copyright}") s end |