Sha256: 65e2e2686492b1f361efbde87adde31293a0affb1f33a711d491f0ae9080dd94

Contents?: true

Size: 607 Bytes

Versions: 1

Compression:

Stored size: 607 Bytes

Contents

# frozen_string_literal: true

require_relative '../../shared/events/base'

module Wizrb
  module Lighting
    module Events
      class SetWarmWhiteEvent < Wizrb::Shared::Events::Base
        MIN_VALUE = 1
        MAX_VALUE = 255

        def initialize(value)
          validate!(value)
          super(method: 'setState', params: { w: value })
        end

        private

        def validate!(value)
          return if value && value >= MIN_VALUE && value <= MAX_VALUE

          raise ArgumentError, "Warm white must be between #{MIN_VALUE} and #{MAX_VALUE}"
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wizrb-1.1.2 lib/wizrb/lighting/events/set_warm_white_event.rb