Class: MicroExiftool::File
- Inherits:
-
Object
- Object
- MicroExiftool::File
- Defined in:
- lib/micro_exiftool/file.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #attributes ⇒ Object
-
#initialize(path) ⇒ File
constructor
A new instance of File.
- #update!(new_attributes) ⇒ Object
Constructor Details
#initialize(path) ⇒ File
Returns a new instance of File.
12 13 14 15 16 17 |
# File 'lib/micro_exiftool/file.rb', line 12 def initialize(path) @path = path.to_s unless ::File.exist?(@path) raise NoSuchFile.new("No such file: #{@path}") end end |
Instance Method Details
#[](key) ⇒ Object
19 20 21 |
# File 'lib/micro_exiftool/file.rb', line 19 def [](key) file_attributes[key] end |
#attributes ⇒ Object
23 24 25 |
# File 'lib/micro_exiftool/file.rb', line 23 def attributes file_attributes.dup end |
#update!(new_attributes) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/micro_exiftool/file.rb', line 27 def update!(new_attributes) update_json = [new_attributes.merge('SourceFile' => @path)].to_json run_exiftool( '-P', # dont change timestamp of file '-G0', # prefix all attributes with "EXIF:", "ITCP:" etc '-overwrite_original', # dont make a backup copy '-j=-', # read new attributes from stdin as json stdin_data: update_json ) @file_attributes = nil true end |