Class: MediaArchiver::MediaFile
- Inherits:
-
Object
- Object
- MediaArchiver::MediaFile
- Defined in:
- lib/media_archiver/media_file.rb
Instance Attribute Summary collapse
-
#exif_tags ⇒ Object
readonly
Returns the value of attribute exif_tags.
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(file_path) ⇒ MediaFile
constructor
A new instance of MediaFile.
- #valid? ⇒ Boolean
Constructor Details
#initialize(file_path) ⇒ MediaFile
Returns a new instance of MediaFile.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/media_archiver/media_file.rb', line 5 def initialize(file_path) @path = file_path @file_name = File.basename(@path) begin @file = MiniExiftool.new(file_path) @exif_tags = @file.to_hash.each_with_object({}) do |(k, v), acc| acc[k.downcase] = v if k end rescue MiniExiftool::Error nil end end |
Instance Attribute Details
#exif_tags ⇒ Object (readonly)
Returns the value of attribute exif_tags.
3 4 5 |
# File 'lib/media_archiver/media_file.rb', line 3 def @exif_tags end |
#file_name ⇒ Object (readonly)
Returns the value of attribute file_name.
3 4 5 |
# File 'lib/media_archiver/media_file.rb', line 3 def file_name @file_name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/media_archiver/media_file.rb', line 3 def path @path end |
Instance Method Details
#valid? ⇒ Boolean
19 20 21 |
# File 'lib/media_archiver/media_file.rb', line 19 def valid? @file && @exif_tags end |