Sha256: 646183da29daa65b41bd3c9a83ed3bcdc05f1122aac42189a306467ab7b41764
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
require 'securerandom' require 'pry' module MilkMaid class Batch attr_accessor :name, :batch_guid, :temperature, :duration, :size, :notifier, :sensor, :nap_time def initialize(options = {}) options.each { |key, value| send("#{key}=", value) } @batch_guid = generate_guid end def compare_temperature(current_temperature) notifier.log_temperature(current_temperature) current_temperature >= temperature end 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 def temperature=(value) @temperature = value.to_f end private def generate_guid ::SecureRandom.uuid end def take_a_nap sleep nap_time end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
milk_maid-0.6.1 | lib/milk_maid/batch.rb |