Class: Group

Inherits:
HueResource show all
Defined in:
lib/ha/group.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from HueResource

#gen_reskey

Constructor Details

#initialize(key, hashvalue) ⇒ Group

Returns a new instance of Group.



4
5
6
7
8
9
10
# File 'lib/ha/group.rb', line 4

def initialize(key, hashvalue)
  super
  @lights = hashvalue["lights"]
  @lights_s = hashvalue["lights"].join(",")
  gen_reskey("g")
  @state.merge! ({"on" =>@lights_s, "name" => @name, "detail" => @detail})
end

Instance Attribute Details

#detailObject (readonly)

Returns the value of attribute detail.



3
4
5
# File 'lib/ha/group.rb', line 3

def detail
  @detail
end

#lightsObject (readonly)

Returns the value of attribute lights.



3
4
5
# File 'lib/ha/group.rb', line 3

def lights
  @lights
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/ha/group.rb', line 3

def name
  @name
end

#onObject (readonly)

Returns the value of attribute on.



3
4
5
# File 'lib/ha/group.rb', line 3

def on
  @on
end

Class Method Details

.owning(number, grouparray) ⇒ Object



16
17
18
# File 'lib/ha/group.rb', line 16

def self.owning(number, grouparray)
  grouparray.select { |group| group.lights.include? number}
end

Instance Method Details

#array(selectors) ⇒ Object



12
13
14
# File 'lib/ha/group.rb', line 12

def array(selectors)
  selectors.map { |key| @state[key] }
end