Class: MarsBase10::MissionControl

Inherits:
Object
  • Object
show all
Defined in:
lib/mars_base_10/mission_control.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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.
  sleep 2  # This is temporary for now, we need a way to know that the subscription callbacks have finished.
  @viewport = Viewport.new
  @controller = GroupRoom.new manager: self, ship_connection: @ship, viewport: @viewport
end

Instance Attribute Details

#controllerObject

Returns the value of attribute controller.



13
14
15
# File 'lib/mars_base_10/mission_control.rb', line 13

def controller
  @controller
end

#shipObject (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

#activateObject



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: {})
  @viewport.dispose_panes
  self.controller = controller_class.send(:new, {manager: self, ship_connection: self.ship, viewport: @viewport, options: options})
end

#shutdownObject



33
34
35
# File 'lib/mars_base_10/mission_control.rb', line 33

def shutdown
  self.controller.stop
end

#swap_controllerObject



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