Class: Rule

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from HueResource

#gen_reskey

Constructor Details

#initialize(key, hashvalue) ⇒ Rule

Returns a new instance of Rule.



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

def initialize(key, hashvalue)
  super(key, hashvalue)
  @detail = "#{hashvalue["conditions"].length} conds => #{hashvalue["actions"].length} acts"
  @state.merge! ({"on" => @hash_value["status"], "name" => @name, "detail" => @detail})
  gen_reskey("r")
end

Instance Attribute Details

#detailObject (readonly)

Returns the value of attribute detail.



4
5
6
# File 'lib/ha/rule.rb', line 4

def detail
  @detail
end

#lightsObject (readonly)

Returns the value of attribute lights.



4
5
6
# File 'lib/ha/rule.rb', line 4

def lights
  @lights
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/ha/rule.rb', line 4

def name
  @name
end

#onObject (readonly)

Returns the value of attribute on.



4
5
6
# File 'lib/ha/rule.rb', line 4

def on
  @on
end

Class Method Details

.owning(number, grouparray) ⇒ Object



16
17
18
# File 'lib/ha/rule.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/rule.rb', line 12

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