Class: Terminal::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/tmrb/session.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session_name, window_name, command) ⇒ Session

Create the session

Parameters:

  • session_name (String)

    the name of the session

  • window_name (String)

    the name of the first window of the session

  • command (String)

    the command which should be executed in the first window of the session



10
11
12
13
14
15
16
17
# File 'lib/tmrb/session.rb', line 10

def initialize(session_name, window_name, command)

  @session_name = session_name
  @window_name = window_name
  @command = command
  @windows = []
  @active_window = 1
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



3
4
5
# File 'lib/tmrb/session.rb', line 3

def command
  @command
end

#session_nameObject (readonly)

Returns the value of attribute session_name.



3
4
5
# File 'lib/tmrb/session.rb', line 3

def session_name
  @session_name
end

#window_nameObject (readonly)

Returns the value of attribute window_name.



3
4
5
# File 'lib/tmrb/session.rb', line 3

def window_name
  @window_name
end

Instance Method Details

#active_window(num) ⇒ Integer

Set the active window in that session

Parameters:

  • num (Integer)

    the number of the active window of that session

Returns:

  • (Integer)

    the number of the active window



23
24
25
# File 'lib/tmrb/session.rb', line 23

def active_window(num)
  @active_window=num
end

#add_window(window) ⇒ Window

Add a window to the session

Parameters:

  • window (Window)

    the object containing the window which should be added to the session

Returns:

  • (Window)

    the object itself



70
71
72
# File 'lib/tmrb/session.rb', line 70

def add_window(window)
  @windows << window
end

#to_stringString

Build the whole session string for tmux

Returns:

  • (String)

    tmux session



30
31
32
33
34
35
# File 'lib/tmrb/session.rb', line 30

def to_string
  w_defs ||= build_window_string
  s_opts ||= build_session_options

  %Q{new-session #{s_opts} "#{command}"\\;#{w_defs}}
end