Sha256: 0df2990dcdea5cfa81b9b861c9c8d7d7d616d9393673212ee5fa31081085ee0c
Contents?: true
Size: 500 Bytes
Versions: 1
Compression:
Stored size: 500 Bytes
Contents
module Milight class Brightness MIN = 2 MAX = 27 def initialize percent raise invalid_brightness unless valid_brightness?(percent) @percent = percent end def to_milight_brightness MIN + ((MAX - MIN) * @percent / 100).round end private def invalid_brightness ArgumentError.new 'Brightness must be given as a percentage (0 - 100)' end def valid_brightness? percentage percentage >= 0 && percentage <= 100 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
milight-easybulb-1.0.0 | lib/milight/brightness.rb |