lib/whipped-cream/sensor.rb in whipped-cream-0.1.0 vs lib/whipped-cream/sensor.rb in whipped-cream-0.1.1

- old
+ new

@@ -6,9 +6,16 @@ # state changes. class Sensor < Control attr_reader :name, :pin, :low, :high, :on_low, :on_high, :block def initialize(name, options = {}, &block) + # Pushing nil onto VALID_GPIO_PINS to allow a pinless sensor + raise "Invalid pin. The pin must be one of "\ + "the Raspberry Pi's valid GPIO pins: "\ + "#{VALID_GPIO_PINS}" unless VALID_GPIO_PINS.dup + .push(nil) + .include?(options[:pin]) + @name = name @pin = options[:pin] @low = options[:low] @high = options[:high] @on_low = options[:on_low]