Class: MarsBase10::Controller
- Inherits:
-
Object
- Object
- MarsBase10::Controller
show all
- Defined in:
- lib/mars_base_10/controller.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(manager:, ship_connection:, viewport:, options: {}) ⇒ Controller
Returns a new instance of Controller.
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/mars_base_10/controller.rb', line 11
def initialize(manager:, ship_connection:, viewport:, options: {})
@manager = manager
@ship = Ship.new connection: ship_connection
@stack = Stack.new
@viewport = viewport
@viewport.controller = self
self.wire_up_panes
self.action_bar = ActionBar.Default.add_action({'i': 'Inspect'})
self.viewport.activate pane: @pane_1
self.show
end
|
Instance Attribute Details
#manager ⇒ Object
Returns the value of attribute manager.
9
10
11
|
# File 'lib/mars_base_10/controller.rb', line 9
def manager
@manager
end
|
#panes ⇒ Object
Returns the value of attribute panes.
9
10
11
|
# File 'lib/mars_base_10/controller.rb', line 9
def panes
@panes
end
|
#ship ⇒ Object
Returns the value of attribute ship.
9
10
11
|
# File 'lib/mars_base_10/controller.rb', line 9
def ship
@ship
end
|
#viewport ⇒ Object
Returns the value of attribute viewport.
9
10
11
|
# File 'lib/mars_base_10/controller.rb', line 9
def viewport
@viewport
end
|
Instance Method Details
#action_bar ⇒ Object
24
25
26
|
# File 'lib/mars_base_10/controller.rb', line 24
def action_bar
self.viewport.action_bar
end
|
#active_node ⇒ Object
28
29
30
|
# File 'lib/mars_base_10/controller.rb', line 28
def active_node
self.ship.fetch_node(resource: self.active_resource, index: self.active_node_index)
end
|
#active_resource ⇒ Object
32
33
34
|
# File 'lib/mars_base_10/controller.rb', line 32
def active_resource
@pane_1.current_subject_index
end
|
#show ⇒ Object
36
37
38
|
# File 'lib/mars_base_10/controller.rb', line 36
def show
self.resync
end
|
#start ⇒ Object
40
41
42
|
# File 'lib/mars_base_10/controller.rb', line 40
def start
self.viewport.open
end
|
#stop ⇒ Object
44
45
46
|
# File 'lib/mars_base_10/controller.rb', line 44
def stop
self.viewport.close
end
|