Class: Blinky::LightFactory
- Inherits:
-
Object
- Object
- Blinky::LightFactory
- Defined in:
- lib/blinky/light_factory.rb
Class Method Summary collapse
Class Method Details
.detect_lights(plugins, recipes) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/blinky/light_factory.rb', line 4 def self.detect_lights plugins, recipes lights = [] found_devices = [] USB.devices.each do |device| found_devices << device matching_recipe = recipes[device.idVendor][device.idProduct] if matching_recipe lights << Light.new(device.open, matching_recipe, plugins) end end raise NoSupportedDevicesFound.new found_devices if lights.empty? lights end |