Class: Hospital::CheckupGroup
- Inherits:
-
Object
- Object
- Hospital::CheckupGroup
- Defined in:
- lib/hospital/checkup_group.rb
Instance Attribute Summary collapse
-
#checkups ⇒ Object
readonly
Returns the value of attribute checkups.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#precondition_checkups ⇒ Object
readonly
Returns the value of attribute precondition_checkups.
-
#skipped ⇒ Object
readonly
Returns the value of attribute skipped.
Instance Method Summary collapse
- #add_checkup(checkup) ⇒ Object
- #all_checkups ⇒ Object
- #header ⇒ Object
-
#initialize(name) ⇒ CheckupGroup
constructor
A new instance of CheckupGroup.
- #run_checkups(verbose: false) ⇒ Object
- #run_dependent_checkups(verbose: false) ⇒ Object
- #run_precondition_checkups(verbose: false) ⇒ Object
Constructor Details
#initialize(name) ⇒ CheckupGroup
Returns a new instance of CheckupGroup.
9 10 11 12 13 14 |
# File 'lib/hospital/checkup_group.rb', line 9 def initialize name @name = name @precondition_checkups = [] @checkups = [] @skipped = false end |
Instance Attribute Details
#checkups ⇒ Object (readonly)
Returns the value of attribute checkups.
7 8 9 |
# File 'lib/hospital/checkup_group.rb', line 7 def checkups @checkups end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/hospital/checkup_group.rb', line 7 def name @name end |
#precondition_checkups ⇒ Object (readonly)
Returns the value of attribute precondition_checkups.
7 8 9 |
# File 'lib/hospital/checkup_group.rb', line 7 def precondition_checkups @precondition_checkups end |
#skipped ⇒ Object (readonly)
Returns the value of attribute skipped.
7 8 9 |
# File 'lib/hospital/checkup_group.rb', line 7 def skipped @skipped end |
Instance Method Details
#add_checkup(checkup) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/hospital/checkup_group.rb', line 24 def add_checkup checkup checkup.set_group self if checkup.precondition @precondition_checkups << checkup else @checkups << checkup end end |
#all_checkups ⇒ Object
16 17 18 |
# File 'lib/hospital/checkup_group.rb', line 16 def all_checkups @precondition_checkups + @checkups end |
#header ⇒ Object
20 21 22 |
# File 'lib/hospital/checkup_group.rb', line 20 def header "#{name.to_s.capitalize.gsub(/_/, ' ')} checks" end |
#run_checkups(verbose: false) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/hospital/checkup_group.rb', line 34 def run_checkups verbose: false run_precondition_checkups verbose: verbose unless @skipped run_dependent_checkups verbose: verbose end end |
#run_dependent_checkups(verbose: false) ⇒ Object
49 50 51 52 53 |
# File 'lib/hospital/checkup_group.rb', line 49 def run_dependent_checkups verbose: false @checkups.each do |checkup| checkup.check verbose: verbose end end |
#run_precondition_checkups(verbose: false) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/hospital/checkup_group.rb', line 42 def run_precondition_checkups verbose: false @precondition_checkups.each do |checkup| checkup.check verbose: verbose @skipped = true unless checkup.success? end end |