class Patterns::Doctor
Doctor class that contains shared functions for all Doctor child classes
Attributes
patients_seen[RW]
Number: Number of patients seen
saw_patient[RW]
Boolean: has the doctor seen a patient?
Public Class Methods
new(next_node = nil)
click to toggle source
Calls the ChainNode initialize function and sets patients seen = 0
Calls superclass method
Patterns::ChainNode.new
# File app/models/chain_of_responsibility/doctor.rb, line 12 def initialize(next_node = nil) super(next_node) @patients_seen = 0 end
Public Instance Methods
process(argument)
click to toggle source
# File app/models/chain_of_responsibility/doctor.rb, line 23 def process(argument) see_patient(argument) end
saw_patient?()
click to toggle source
Returns true or false if the doctor has seen a patient
# File app/models/chain_of_responsibility/doctor.rb, line 28 def saw_patient? if @saw_patient true else false end end
see_patient(patient)
click to toggle source
Sets saw patient = true and adds 1 to patients seen
# File app/models/chain_of_responsibility/doctor.rb, line 18 def see_patient(patient) @saw_patient = true @patients_seen += 1 end