Class: Winker::Scene

Inherits:
Object
  • Object
show all
Defined in:
lib/winker/scene.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj_data) ⇒ Scene

Returns a new instance of Scene.



11
12
13
14
# File 'lib/winker/scene.rb', line 11

def initialize(obj_data)
  @obj_data = obj_data
  @id = @obj_data.scene_id
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_sym, *arguments, &block) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/winker/scene.rb', line 28

def method_missing(method_sym, *arguments, &block)
  
  if obj_data.respond_to?(method_sym)
    obj_data.send(method_sym, *arguments, &block)
  else
    super
  end
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/winker/scene.rb', line 5

def id
  @id
end

#obj_dataObject

Returns the value of attribute obj_data.



5
6
7
# File 'lib/winker/scene.rb', line 5

def obj_data
  @obj_data
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/winker/scene.rb', line 5

def type
  @type
end

Class Method Details

.load_scenes(data) ⇒ Object



7
8
9
# File 'lib/winker/scene.rb', line 7

def self.load_scenes(data)
  data.map{|s| Winker::Scene.new(s)}
end

Instance Method Details

#activateObject



24
25
26
# File 'lib/winker/scene.rb', line 24

def activate
  Winker.activate_scene(self.id)
end

#membersObject



16
17
18
# File 'lib/winker/scene.rb', line 16

def members
  devices.select{|d| @obj_data.members.map{|m| m[:object_id]}.include?(d.id)}
end

#settingsObject



20
21
22
# File 'lib/winker/scene.rb', line 20

def settings
  @obj_data.members
end