Class: ToPass::AlgorithmReader

Inherits:
FileReader show all
Defined in:
lib/to_pass/algorithm_reader.rb

Overview

The AlgorithmReader’s primary API is to load the rules from a YAML-file into a Hash.

Algorithms are searched in a list of standard directories. Those are defined and managed in ToPass::Directories

see ToPass::Converter for usage of the loaded algorithm

Instance Attribute Summary

Attributes inherited from FileReader

#load_path

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from FileReader

discover, load, search_pattern, #standard_directories

Constructor Details

#initialize(algorithm) ⇒ AlgorithmReader

:nodoc:



14
15
16
# File 'lib/to_pass/algorithm_reader.rb', line 14

def initialize(algorithm) # :nodoc:
  super(algorithm, 'algorithms')
end

Class Method Details

.extensionObject

:nodoc:



19
20
21
# File 'lib/to_pass/algorithm_reader.rb', line 19

def extension # :nodoc:
  'yml'
end

Instance Method Details

#load_from_fileObject

:nodoc:



24
25
26
27
28
29
30
# File 'lib/to_pass/algorithm_reader.rb', line 24

def load_from_file # :nodoc:
  fn = super

  YAML.load_file(fn.expand_path)
rescue LoadError
  raise LoadError, "algorithm #{@file} could not be found in #{load_path.join(', ')}" if fn.nil?
end