Class: Ace::Tmux::Models::Session
- Inherits:
-
Object
- Object
- Ace::Tmux::Models::Session
- Defined in:
- lib/ace/tmux/models/session.rb
Overview
Represents a tmux session configuration
Instance Attribute Summary collapse
-
#attach ⇒ Object
readonly
Returns the value of attribute attach.
-
#name ⇒ Object
Returns the value of attribute name.
-
#on_project_exit ⇒ Object
readonly
Returns the value of attribute on_project_exit.
-
#on_project_start ⇒ Object
readonly
Returns the value of attribute on_project_start.
-
#pre_window ⇒ Object
readonly
Returns the value of attribute pre_window.
-
#root ⇒ Object
Returns the value of attribute root.
-
#startup_window ⇒ Object
readonly
Returns the value of attribute startup_window.
-
#tmux_options ⇒ Object
readonly
Returns the value of attribute tmux_options.
-
#windows ⇒ Object
readonly
Returns the value of attribute windows.
Instance Method Summary collapse
- #attach? ⇒ Boolean
-
#initialize(name:, root: nil, windows: [], pre_window: nil, startup_window: nil, on_project_start: [], on_project_exit: [], attach: true, tmux_options: nil) ⇒ Session
constructor
A new instance of Session.
- #to_h ⇒ Object
Constructor Details
#initialize(name:, root: nil, windows: [], pre_window: nil, startup_window: nil, on_project_start: [], on_project_exit: [], attach: true, tmux_options: nil) ⇒ Session
Returns a new instance of Session.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ace/tmux/models/session.rb', line 21 def initialize( name:, root: nil, windows: [], pre_window: nil, startup_window: nil, on_project_start: [], on_project_exit: [], attach: true, tmux_options: nil ) @name = name @root = root @windows = windows @pre_window = pre_window @startup_window = startup_window @on_project_start = Array(on_project_start) @on_project_exit = Array(on_project_exit) @attach = attach @tmux_options = end |
Instance Attribute Details
#attach ⇒ Object (readonly)
Returns the value of attribute attach.
8 9 10 |
# File 'lib/ace/tmux/models/session.rb', line 8 def attach @attach end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/ace/tmux/models/session.rb', line 8 def name @name end |
#on_project_exit ⇒ Object (readonly)
Returns the value of attribute on_project_exit.
8 9 10 |
# File 'lib/ace/tmux/models/session.rb', line 8 def on_project_exit @on_project_exit end |
#on_project_start ⇒ Object (readonly)
Returns the value of attribute on_project_start.
8 9 10 |
# File 'lib/ace/tmux/models/session.rb', line 8 def on_project_start @on_project_start end |
#pre_window ⇒ Object (readonly)
Returns the value of attribute pre_window.
8 9 10 |
# File 'lib/ace/tmux/models/session.rb', line 8 def pre_window @pre_window end |
#root ⇒ Object
Returns the value of attribute root.
8 9 10 |
# File 'lib/ace/tmux/models/session.rb', line 8 def root @root end |
#startup_window ⇒ Object (readonly)
Returns the value of attribute startup_window.
8 9 10 |
# File 'lib/ace/tmux/models/session.rb', line 8 def startup_window @startup_window end |
#tmux_options ⇒ Object (readonly)
Returns the value of attribute tmux_options.
8 9 10 |
# File 'lib/ace/tmux/models/session.rb', line 8 def @tmux_options end |
#windows ⇒ Object (readonly)
Returns the value of attribute windows.
8 9 10 |
# File 'lib/ace/tmux/models/session.rb', line 8 def windows @windows end |
Instance Method Details
#attach? ⇒ Boolean
43 44 45 |
# File 'lib/ace/tmux/models/session.rb', line 43 def attach? @attach != false end |
#to_h ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/ace/tmux/models/session.rb', line 47 def to_h hash = { "name" => @name, "windows" => @windows.map(&:to_h), "attach" => @attach } hash["root"] = @root if @root hash["pre_window"] = @pre_window if @pre_window hash["startup_window"] = @startup_window if @startup_window hash["on_project_start"] = @on_project_start unless @on_project_start.empty? hash["on_project_exit"] = @on_project_exit unless @on_project_exit.empty? hash["tmux_options"] = @tmux_options if @tmux_options hash end |