Class: MarsBase10::GraphRover
- Inherits:
-
Controller
- Object
- Controller
- MarsBase10::GraphRover
- Defined in:
- lib/mars_base_10/controller/graph_rover.rb
Instance Attribute Summary
Attributes inherited from Controller
#manager, #panes, #ship, #viewport
Instance Method Summary collapse
- #active_node_index ⇒ Object
- #load_history ⇒ Object
-
#send(key:) ⇒ Object
Called by a pane in this controller for bubbling a key press up.
- #start ⇒ Object
- #stop ⇒ Object
Methods inherited from Controller
#action_bar, #active_node, #active_resource, #initialize, #show
Constructor Details
This class inherits a constructor from MarsBase10::Controller
Instance Method Details
#active_node_index ⇒ Object
7 8 9 |
# File 'lib/mars_base_10/controller/graph_rover.rb', line 7 def active_node_index @node_list_pane.current_subject_index end |
#load_history ⇒ Object
11 12 13 14 15 16 |
# File 'lib/mars_base_10/controller/graph_rover.rb', line 11 def load_history return 0 unless @node_list_pane == self..active_pane new_content = self.ship.fetch_older_nodes(resource: self.active_resource, node: self.active_node) @node_list_pane.subject.prepend_content(ary: new_content) new_content.length end |
#send(key:) ⇒ Object
Called by a pane in this controller for bubbling a key press up
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/mars_base_10/controller/graph_rover.rb', line 21 def send(key:) resync_needed = true case key when 'd' # (D)ive begin if @node_view_pane.subject.contents[4].include?('true') self..add_action({'p': 'Pop Out'}) self..remove_actions([:d, :g]) @stack.push(self.active_resource) @node_list_pane.clear @node_list_pane.subject.contents = self.ship.fetch_node_children(resource: self.active_resource, index: self.active_node_index) end end when 'i' # (I)nspect begin self..activate pane: @node_list_pane self..add_action({'d': 'Dive In', 'g': 'Graph List'}) resync_needed = false end when 'g' # (G)raph View unless @pane_1.active? self..activate pane: @pane_1 # resync_needed = false end when 'p' # (P)op begin if (resource = @stack.pop) @node_list_pane.clear @node_list_pane.subject.contents = self.ship.fetch_node_list(resource: resource) end if (@stack.length == 0) self..remove_actions([:p]) end end when 'X' self.manager.swap_controller end self.resync if resync_needed end |
#start ⇒ Object
61 62 63 |
# File 'lib/mars_base_10/controller/graph_rover.rb', line 61 def start self..open end |
#stop ⇒ Object
65 66 67 |
# File 'lib/mars_base_10/controller/graph_rover.rb', line 65 def stop self..close end |