Class: MilkMaid::Batch
- Inherits:
-
Object
- Object
- MilkMaid::Batch
- Defined in:
- lib/milk_maid/batch.rb
Instance Attribute Summary collapse
-
#batch_guid ⇒ Object
Returns the value of attribute batch_guid.
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#name ⇒ Object
Returns the value of attribute name.
-
#nap_time ⇒ Object
Returns the value of attribute nap_time.
-
#notifier ⇒ Object
Returns the value of attribute notifier.
-
#sensor ⇒ Object
Returns the value of attribute sensor.
-
#size ⇒ Object
Returns the value of attribute size.
-
#temperature ⇒ Object
Returns the value of attribute temperature.
Instance Method Summary collapse
- #compare_temperature(current_temperature) ⇒ Object
-
#initialize(options = {}) ⇒ Batch
constructor
A new instance of Batch.
- #start ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Batch
Returns a new instance of Batch.
8 9 10 11 12 |
# File 'lib/milk_maid/batch.rb', line 8 def initialize( = {}) .each { |key, value| send("#{key}=", value) } @batch_guid = generate_guid end |
Instance Attribute Details
#batch_guid ⇒ Object
Returns the value of attribute batch_guid.
6 7 8 |
# File 'lib/milk_maid/batch.rb', line 6 def batch_guid @batch_guid end |
#duration ⇒ Object
Returns the value of attribute duration.
6 7 8 |
# File 'lib/milk_maid/batch.rb', line 6 def duration @duration end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/milk_maid/batch.rb', line 6 def name @name end |
#nap_time ⇒ Object
Returns the value of attribute nap_time.
6 7 8 |
# File 'lib/milk_maid/batch.rb', line 6 def nap_time @nap_time end |
#notifier ⇒ Object
Returns the value of attribute notifier.
6 7 8 |
# File 'lib/milk_maid/batch.rb', line 6 def notifier @notifier end |
#sensor ⇒ Object
Returns the value of attribute sensor.
6 7 8 |
# File 'lib/milk_maid/batch.rb', line 6 def sensor @sensor end |
#size ⇒ Object
Returns the value of attribute size.
6 7 8 |
# File 'lib/milk_maid/batch.rb', line 6 def size @size end |
#temperature ⇒ Object
Returns the value of attribute temperature.
6 7 8 |
# File 'lib/milk_maid/batch.rb', line 6 def temperature @temperature end |
Instance Method Details
#compare_temperature(current_temperature) ⇒ Object
14 15 16 17 |
# File 'lib/milk_maid/batch.rb', line 14 def compare_temperature(current_temperature) notifier.log_temperature(current_temperature) current_temperature >= temperature end |
#start ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/milk_maid/batch.rb', line 19 def start notifier.batch_started(name: name, guid: batch_guid, duration: duration, base_temperature: temperature, batch_size: size) until compare_temperature(sensor.reading) take_a_nap end ending_time = Time.now + duration notifier.temperature_reached until Time.now > ending_time current_temp = sensor.reading notifier.log_temperature(current_temp) notifier.post_warning(current_temp, temperature) if current_temp < temperature take_a_nap end # log final temperature current_temp = sensor.reading notifier.log_temperature(current_temp) notifier.batch_completed end |