Class: Hydra::FileCharacterization::Characterizer

Inherits:
Object
  • Object
show all
Includes:
Open3
Defined in:
lib/hydra/file_characterization/characterizer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, tool_path = nil) ⇒ Characterizer

Returns a new instance of Characterizer.



12
13
14
15
# File 'lib/hydra/file_characterization/characterizer.rb', line 12

def initialize(filename, tool_path = nil)
  @filename = filename
  @tool_path = tool_path
end

Instance Attribute Details

#filenameObject (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

#callObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/hydra/file_characterization/characterizer.rb', line 17

def call
  unless File.exists?(filename)
    raise Hydra::FileCharacterization::FileNotFoundError.new("File: #{filename} does not exist.")
  end

  if tool_path.respond_to?(:call)
    tool_path.call(filename)
  else
    internal_call
  end
end

#tool_pathObject



29
30
31
# File 'lib/hydra/file_characterization/characterizer.rb', line 29

def tool_path
  @tool_path || self.class.tool_path || (raise Hydra::FileCharacterization::UnspecifiedToolPathError.new(self.class))
end