Class: Fitting::Report::Prefixes
- Inherits:
-
Object
- Object
- Fitting::Report::Prefixes
- Defined in:
- lib/fitting/report/prefixes.rb
Instance Method Summary collapse
- #cram_into_the_appropriate_prefix(test) ⇒ Object
-
#initialize(config_path) ⇒ Prefixes
constructor
A new instance of Prefixes.
- #is_there_a_suitable_prefix?(test_path) ⇒ Boolean
- #join(tests) ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(config_path) ⇒ Prefixes
Returns a new instance of Prefixes.
6 7 8 9 10 11 |
# File 'lib/fitting/report/prefixes.rb', line 6 def initialize(config_path) @prefixes = [] YAML.safe_load(File.read(config_path))['prefixes'].map do |prefix| @prefixes.push(Fitting::Report::Prefix.new(prefix['name'], prefix['tomogram_json_path'], prefix['skip'])) end end |
Instance Method Details
#cram_into_the_appropriate_prefix(test) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/fitting/report/prefixes.rb', line 21 def cram_into_the_appropriate_prefix(test) @prefixes.map do |prefix| if test.path[0..prefix.name.size - 1] == prefix.name prefix.add_test(test) return end end end |
#is_there_a_suitable_prefix?(test_path) ⇒ Boolean
13 14 15 16 17 18 19 |
# File 'lib/fitting/report/prefixes.rb', line 13 def is_there_a_suitable_prefix?(test_path) @prefixes.map do |prefix| return true if test_path[0..prefix.name.size - 1] == prefix.name end false end |
#join(tests) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/fitting/report/prefixes.rb', line 30 def join(tests) tests.to_a.map do |test| if is_there_a_suitable_prefix?(test.path) cram_into_the_appropriate_prefix(test) test.mark_prefix end end end |
#to_a ⇒ Object
39 40 41 |
# File 'lib/fitting/report/prefixes.rb', line 39 def to_a @prefixes end |