Sha256: 30442f45c3933745f09fd9444f827935792aac54bad2fbcc266a572180ce76c1

Contents?: true

Size: 919 Bytes

Versions: 7

Compression:

Stored size: 919 Bytes

Contents

module Hue
  class Scene
    include Enumerable
    include TranslateKeys

    # Unique identification number.
    attr_reader :id

    # Bridge the scene is associated with
    attr_reader :bridge

    # A unique, editable name given to the scene.
    attr_accessor :name

    # Whether or not the scene is active on a group.
    attr_reader :active

    def initialize(client, bridge, id, data)
      @client = client
      @bridge = bridge
      @id = id

      unpack(data)
    end

    def lights
      @lights ||= begin
        @light_ids.map do |light_id|
          @client.light(light_id)
        end
      end
    end

    private

    SCENE_KEYS_MAP = {
      :name => :name,
      :light_ids => :lights,
      :active => :active,
    }

    def unpack(data)
      unpack_hash(data, SCENE_KEYS_MAP)
    end

    def base_url
      "http://#{@bridge.ip}/api/#{@client.username}/scenes/#{id}"
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
hue-0.3.0 lib/hue/scene.rb
huebot-0.4.0 lib/hue/scene.rb
huebot-0.3.0 lib/hue/scene.rb
huebot-0.2.0 lib/hue/scene.rb
hue-0.2.0 lib/hue/scene.rb
hue-0.1.5 lib/hue/scene.rb
hue-0.1.4 lib/hue/scene.rb