Class: Hydra::FileCharacterization::Characterizer
- Inherits:
-
Object
- Object
- Hydra::FileCharacterization::Characterizer
- Includes:
- Open3
- Defined in:
- lib/hydra/file_characterization/characterizer.rb
Direct Known Subclasses
Hydra::FileCharacterization::Characterizers::Ffprobe, Hydra::FileCharacterization::Characterizers::Fits
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(filename) ⇒ Characterizer
constructor
A new instance of Characterizer.
Constructor Details
#initialize(filename) ⇒ Characterizer
Returns a new instance of Characterizer.
12 13 14 |
# File 'lib/hydra/file_characterization/characterizer.rb', line 12 def initialize(filename) @filename = filename end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
11 12 13 |
# File 'lib/hydra/file_characterization/characterizer.rb', line 11 def filename @filename end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/hydra/file_characterization/characterizer.rb', line 16 def call unless File.exists?(filename) raise Hydra::FileCharacterization::FileNotFoundError.new("File: #{filename} does not exist.") end stdin, stdout, stderr, wait_thr = popen3(command) begin out = stdout.read err = stderr.read exit_status = wait_thr.value raise "Unable to execute command \"#{command}\"\n#{err}" unless exit_status.success? out ensure stdin.close stdout.close stderr.close end end |