huebot 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/hue/scene.rb DELETED
@@ -1,50 +0,0 @@
1
- module Hue
2
- class Scene
3
- include Enumerable
4
- include TranslateKeys
5
-
6
- # Unique identification number.
7
- attr_reader :id
8
-
9
- # Bridge the scene is associated with
10
- attr_reader :bridge
11
-
12
- # A unique, editable name given to the scene.
13
- attr_accessor :name
14
-
15
- # Whether or not the scene is active on a group.
16
- attr_reader :active
17
-
18
- def initialize(client, bridge, id, data)
19
- @client = client
20
- @bridge = bridge
21
- @id = id
22
-
23
- unpack(data)
24
- end
25
-
26
- def lights
27
- @lights ||= begin
28
- @light_ids.map do |light_id|
29
- @client.light(light_id)
30
- end
31
- end
32
- end
33
-
34
- private
35
-
36
- SCENE_KEYS_MAP = {
37
- :name => :name,
38
- :light_ids => :lights,
39
- :active => :active,
40
- }
41
-
42
- def unpack(data)
43
- unpack_hash(data, SCENE_KEYS_MAP)
44
- end
45
-
46
- def base_url
47
- "http://#{@bridge.ip}/api/#{@client.username}/scenes/#{id}"
48
- end
49
- end
50
- end
@@ -1,21 +0,0 @@
1
- module Hue
2
- module TranslateKeys
3
- def translate_keys(hash, map)
4
- new_hash = {}
5
- hash.each do |key, value|
6
- new_key = map[key.to_sym]
7
- key = new_key if new_key
8
- new_hash[key] = value
9
- end
10
- new_hash
11
- end
12
-
13
- def unpack_hash(hash, map)
14
- map.each do |local_key, remote_key|
15
- value = hash[remote_key.to_s]
16
- next unless value
17
- instance_variable_set("@#{local_key}", value)
18
- end
19
- end
20
- end
21
- end
data/lib/hue/version.rb DELETED
@@ -1,3 +0,0 @@
1
- module Hue
2
- VERSION = '0.1.5'
3
- end
data/lib/hue.rb DELETED
@@ -1,13 +0,0 @@
1
- require 'hue/version'
2
- require 'hue/errors'
3
- require 'hue/client'
4
- require 'hue/bridge'
5
- require 'hue/editable_state'
6
- require 'hue/translate_keys'
7
- require 'hue/light'
8
- require 'hue/group'
9
- require 'hue/scene'
10
-
11
- module Hue
12
- USERNAME_RANGE = 10..40
13
- end