Class: Wizrb::Shared::Group
- Inherits:
-
Object
- Object
- Wizrb::Shared::Group
show all
- Includes:
- Enumerable
- Defined in:
- lib/wizrb/shared/group.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(devices:) ⇒ Group
Returns a new instance of Group.
16
17
18
|
# File 'lib/wizrb/shared/group.rb', line 16
def initialize(devices:)
@devices = devices
end
|
Instance Attribute Details
#devices ⇒ Object
Returns the value of attribute devices.
14
15
16
|
# File 'lib/wizrb/shared/group.rb', line 14
def devices
@devices
end
|
Instance Method Details
#dispatch_event(event) ⇒ Object
40
41
42
43
44
45
46
|
# File 'lib/wizrb/shared/group.rb', line 40
def dispatch_event(event)
unless event.is_a?(Wizrb::Shared::Events::Base)
raise ArgumentError, "Not an instance of Wizrb::Shared::Events::Base"
end
dispatch(event)
end
|
#dispatch_events(*events) ⇒ Object
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/wizrb/shared/group.rb', line 48
def dispatch_events(*events)
events.each do |event|
unless event.is_a?(Wizrb::Shared::Events::Base)
raise ArgumentError, "Not an instance of Wizrb::Shared::Events::Base"
end
end
params = events.reduce({}) { |h, e| h.merge(e.params) }
dispatch_event(Wizrb::Shared::Events::Base.new(method: "setState", params: params))
end
|
#each ⇒ Object
20
21
22
|
# File 'lib/wizrb/shared/group.rb', line 20
def each(&)
@devices.each(&)
end
|