Class: WhatToDo::CheckManager
- Inherits:
-
Object
- Object
- WhatToDo::CheckManager
- Defined in:
- lib/whatToDo/check_manager.rb
Instance Method Summary collapse
- #check(facets = [], &block) ⇒ Object
-
#initialize(facets = []) ⇒ CheckManager
constructor
A new instance of CheckManager.
- #run_checks(count) ⇒ Object
Constructor Details
#initialize(facets = []) ⇒ CheckManager
Returns a new instance of CheckManager.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/whatToDo/check_manager.rb', line 5 def initialize(facets = []) @checks = [] @facets = facets # Require all check scripts dir = Pathname.new(File.dirname(__FILE__) + '/check').cleanpath Dir["#{dir}/*.rb"].each do |file| instance_eval(File.open(File.(file)).read) end end |
Instance Method Details
#check(facets = [], &block) ⇒ Object
16 17 18 19 20 |
# File 'lib/whatToDo/check_manager.rb', line 16 def check(facets = [], &block) if !facets.any? || (facets & @facets).any? @checks << block end end |
#run_checks(count) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/whatToDo/check_manager.rb', line 22 def run_checks(count) results = [] @checks.each do |check| result = instance_eval(&check) unless result == nil || result == false results << result break if results.length >= count end end results end |