Class: Artoo::Master
Overview
The Artoo::Master class is a registered supervisor class to keep track of all the running robots
Instance Attribute Summary collapse
-
#robots ⇒ Object
readonly
Returns the value of attribute robots.
Instance Method Summary collapse
-
#continue_work ⇒ Object
Continue work for each robot.
-
#initialize(bots) ⇒ Master
constructor
Create new master.
-
#pause_work ⇒ Object
Pause work for each robot.
-
#robot(name) ⇒ Robot
Robot.
-
#robot_connection(robot_id, connection_id) ⇒ Device
Robot connection.
-
#robot_connections(name) ⇒ Collection
Robot connections.
-
#robot_device(name, device_id) ⇒ Device
Robot device.
-
#robot_devices(name) ⇒ Collection
Robot devices.
-
#start_work ⇒ Object
Do asynchronous work for each robot.
-
#stop_work ⇒ Object
terminate all robots.
Constructor Details
#initialize(bots) ⇒ Master
Create new master
10 11 12 |
# File 'lib/artoo/master.rb', line 10 def initialize(bots) @robots = bots end |
Instance Attribute Details
#robots ⇒ Object (readonly)
Returns the value of attribute robots.
6 7 8 |
# File 'lib/artoo/master.rb', line 6 def robots @robots end |
Instance Method Details
#continue_work ⇒ Object
Continue work for each robot
61 62 63 |
# File 'lib/artoo/master.rb', line 61 def continue_work robots.each {|r| r.async.continue_work} end |
#pause_work ⇒ Object
Pause work for each robot
53 54 55 56 57 58 |
# File 'lib/artoo/master.rb', line 53 def pause_work robots.each {|r| Logger.info "pausing #{r.name}" r.async.pause_work } end |
#robot(name) ⇒ Robot
Returns robot.
16 17 18 |
# File 'lib/artoo/master.rb', line 16 def robot(name) robots.find {|r| r.name == name} end |
#robot_connection(robot_id, connection_id) ⇒ Device
Returns robot connection.
42 43 44 |
# File 'lib/artoo/master.rb', line 42 def robot_connection(robot_id, connection_id) robot_connections(robot_id)[connection_id.intern] end |
#robot_connections(name) ⇒ Collection
Returns robot connections.
35 36 37 |
# File 'lib/artoo/master.rb', line 35 def robot_connections(name) robot(name).connections end |
#robot_device(name, device_id) ⇒ Device
Returns robot device.
29 30 31 |
# File 'lib/artoo/master.rb', line 29 def robot_device(name, device_id) robot_devices(name)[device_id.intern] end |
#robot_devices(name) ⇒ Collection
Returns robot devices.
22 23 24 |
# File 'lib/artoo/master.rb', line 22 def robot_devices(name) robot(name).devices end |