class Teamocil::Tmux::Session

Public Class Methods

new(object) click to toggle source
Calls superclass method
# File lib/teamocil/tmux/session.rb, line 4
def initialize(object)
  super

  # Sessions need a name
  self.name = "teamocil-session-#{rand(1_000_000)}" unless name

  self.windows = windows.each_with_index.map do |window, index|
    # Windows need to know their position
    window.merge! index: index

    Teamocil::Tmux::Window.new(window)
  end
end

Public Instance Methods

as_tmux() click to toggle source
# File lib/teamocil/tmux/session.rb, line 18
def as_tmux
  [].tap do |tmux|
    tmux << Teamocil::Command::RenameSession.new(name: name)
    tmux << windows.map(&:as_tmux)

    # Set the focus on the right window or do nothing
    focused_window = windows.find(&:focus)
    tmux << Teamocil::Command::SelectWindow.new(index: focused_window.internal_index) if focused_window
  end.flatten
end