Sha256: db646854df680d6b50644304dc4e32345c24de0d3b8d2dc96088d148fa9d2572
Contents?: true
Size: 734 Bytes
Versions: 5
Compression:
Stored size: 734 Bytes
Contents
require 'w1temp' module MilkMaid class SensorException < RuntimeError; end class TemperatureSensor def initialize @sensor = Temperature.new fail ::MilkMaid::SensorException.new 'Sensor not available' unless @sensor.name end def name return "No sensor attached" unless @sensor.display @sensor.name end def reading return "Reading: No sensor attached" unless @sensor.display @sensor.reading end end class MockTemperatureSensor def initialize(low_temp, high_temp) @low_temp = low_temp.to_i @high_temp = high_temp.to_i end def name 'MockTemperatureSensor' end def reading rand(@low_temp..@high_temp) end end end
Version data entries
5 entries across 5 versions & 1 rubygems