Class: MarsBase10::GroupRoom

Inherits:
Controller show all
Defined in:
lib/mars_base_10/controller/group_room.rb

Instance Attribute Summary

Attributes inherited from Controller

#manager, #panes, #ship, #viewport

Instance Method Summary collapse

Methods inherited from Controller

#action_bar, #active_node, #active_resource, #initialize, #show, #start, #stop

Constructor Details

This class inherits a constructor from MarsBase10::Controller

Instance Method Details

#active_subject(pane:) ⇒ Object



7
8
9
# File 'lib/mars_base_10/controller/group_room.rb', line 7

def active_subject(pane:)
  pane.current_subject_index
end

#load_historyObject



11
12
13
14
15
16
# File 'lib/mars_base_10/controller/group_room.rb', line 11

def load_history
  return 0 unless @pane_3 == self.viewport.active_pane
  new_content = self.ship.fetch_older_nodes(resource: self.active_resource, node: self.active_node)
  @pane_3.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
# File 'lib/mars_base_10/controller/group_room.rb', line 21

def send(key:)
  resync_needed = true
  case key
  when 'g'    # (G)raph View
    unless @pane_1.active?
      self.action_bar.remove_actions([:r])
      self.viewport.activate pane: @pane_1
    end
  when 'i'    # (I)nspect
    begin
      resync_needed = false
      self.action_bar.add_action({'g': 'Group List'})
      self.action_bar.add_action({'r': 'Read Channel'})
      self.viewport.activate pane: @pane_3
    end
  when 'r'    # (r)ead -> go to the Social Lounge
    if @pane_3.active?
      resync_needed = false
      self.action_bar.remove_actions([:g, :r])
      opts = {
        group_title:   self.active_subject(pane: @pane_1),
        channel_title: self.active_subject(pane: @pane_3)
      }
      self.manager.assign(controller_class: SocialLounge, options: opts)
    end
  when 'X'
    resync_needed = false
    self.manager.swap_controller
  end
  self.resync if resync_needed
end