Class: Depix::Editor
- Inherits:
-
Delegator
- Object
- Delegator
- Depix::Editor
- Defined in:
- lib/depix/editor.rb
Overview
Used to edit DPX headers. Create an Editor object and pass the path to the file to it. Change the headers variable to contain the edited DPX headers and call commit!. Note that the DPX header will be overwritten in place - if you want to save another version you need to manage it yourself.
dpx = Depix::Editor.new("/RAID/scans/1374470_adjusted.dpx")
dpx.file.copyright = "Copyleft"
dpx.file.reserve = "FileReserve"
dpx.orientation.reserve = "OrientReserve"
dpx.orientation.device = "Chainik"
dpx.orientation.serial = "43"
dpx.film.reserve = "FilmRezerve"
dpx.file.project = "Mastermind"
dpx.commit! # will write out the headers
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Stores the path to file.
Instance Method Summary collapse
- #__getobj__ ⇒ Object
-
#commit! ⇒ Object
Save the headers to file at path, overwriting the old ones.
-
#headers ⇒ Object
DEPRECATED.
-
#initialize(file_path) ⇒ Editor
constructor
Create a new editor for the file at path.
Constructor Details
Instance Attribute Details
#path ⇒ Object (readonly)
Stores the path to file
21 22 23 |
# File 'lib/depix/editor.rb', line 21 def path @path end |
Instance Method Details
#__getobj__ ⇒ Object
50 51 52 |
# File 'lib/depix/editor.rb', line 50 def __getobj__ @dpx # return object we are delegating to, required end |
#commit! ⇒ Object
Save the headers to file at path, overwriting the old ones
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/depix/editor.rb', line 30 def commit! raise "No headers" unless @dpx raise "Cannot pack LE headers yet" if @dpx.le? packed = @dpx.class.pack(@dpx) # Validate that we can unpack first - what if something went wrong? Depix::Reader.new.parse(packed, false) # Use in-place writing into DPX file (this is what + does) File.open(@path, 'rb+') do | f | f.seek(0, IO::SEEK_SET); f.write(packed) end end |
#headers ⇒ Object
DEPRECATED
45 46 47 48 |
# File 'lib/depix/editor.rb', line 45 def headers STDERR.puts "Depix::Editor#headers is deprecated, use the Editor itself instead" self end |