Class: MarsBase10::MissionControl
- Inherits:
-
Object
- Object
- MarsBase10::MissionControl
- Defined in:
- lib/mars_base_10/mission_control.rb
Instance Attribute Summary collapse
-
#controller ⇒ Object
Returns the value of attribute controller.
-
#ship ⇒ Object
readonly
Returns the value of attribute ship.
Instance Method Summary collapse
- #activate ⇒ Object
- #assign(controller_class:, options: {}) ⇒ Object
-
#initialize(config_filename:) ⇒ MissionControl
constructor
A new instance of MissionControl.
- #shutdown ⇒ Object
- #swap_controller ⇒ Object
Constructor Details
#initialize(config_filename:) ⇒ MissionControl
16 17 18 19 20 21 22 |
# File 'lib/mars_base_10/mission_control.rb', line 16 def initialize(config_filename:) @ship = Urbit.connect(config_file: config_filename) @ship.login sleep 2 # This is temporary for now, we need a way to know that the subscription callbacks have finished. = Viewport.new @controller = GroupRoom.new manager: self, ship_connection: @ship, viewport: end |
Instance Attribute Details
#controller ⇒ Object
Returns the value of attribute controller.
13 14 15 |
# File 'lib/mars_base_10/mission_control.rb', line 13 def controller @controller end |
#ship ⇒ Object (readonly)
Returns the value of attribute ship.
14 15 16 |
# File 'lib/mars_base_10/mission_control.rb', line 14 def ship @ship end |
Instance Method Details
#activate ⇒ Object
24 25 26 |
# File 'lib/mars_base_10/mission_control.rb', line 24 def activate self.controller.start end |
#assign(controller_class:, options: {}) ⇒ Object
28 29 30 31 |
# File 'lib/mars_base_10/mission_control.rb', line 28 def assign(controller_class:, options: {}) .dispose_panes self.controller = controller_class.send(:new, {manager: self, ship_connection: self.ship, viewport: , options: }) end |
#shutdown ⇒ Object
33 34 35 |
# File 'lib/mars_base_10/mission_control.rb', line 33 def shutdown self.controller.stop end |
#swap_controller ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/mars_base_10/mission_control.rb', line 37 def swap_controller if GroupRoom == self.controller.class cls = GraphRover elsif GraphRover == self.controller.class cls = SocialLounge else cls = GroupRoom end self.assign(controller_class: cls) end |