Class: Ace::Tmux::Models::Pane

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/tmux/models/pane.rb

Overview

Represents a tmux pane configuration

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(commands: [], focus: false, root: nil, name: nil, options: {}) ⇒ Pane

Returns a new instance of Pane.

Parameters:

  • commands (Array<String>) (defaults to: [])

    Commands to run in the pane

  • focus (Boolean) (defaults to: false)

    Whether this pane should be focused

  • root (String, nil) (defaults to: nil)

    Working directory for the pane

  • name (String, nil) (defaults to: nil)

    Optional pane name

  • options (Hash) (defaults to: {})

    Raw tmux pane options (passed to set-option -p)



15
16
17
18
19
20
21
# File 'lib/ace/tmux/models/pane.rb', line 15

def initialize(commands: [], focus: false, root: nil, name: nil, options: {})
  @commands = Array(commands)
  @focus = focus
  @root = root
  @name = name
  @options = options || {}
end

Instance Attribute Details

#commandsObject (readonly)

Returns the value of attribute commands.



8
9
10
# File 'lib/ace/tmux/models/pane.rb', line 8

def commands
  @commands
end

#focusObject (readonly)

Returns the value of attribute focus.



8
9
10
# File 'lib/ace/tmux/models/pane.rb', line 8

def focus
  @focus
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/ace/tmux/models/pane.rb', line 8

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/ace/tmux/models/pane.rb', line 8

def options
  @options
end

#rootObject (readonly)

Returns the value of attribute root.



8
9
10
# File 'lib/ace/tmux/models/pane.rb', line 8

def root
  @root
end

Instance Method Details

#focus?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/ace/tmux/models/pane.rb', line 23

def focus?
  @focus == true
end

#to_hObject



27
28
29
30
31
32
33
# File 'lib/ace/tmux/models/pane.rb', line 27

def to_h
  hash = {"commands" => @commands, "focus" => @focus}
  hash["root"] = @root if @root
  hash["name"] = @name if @name
  hash["options"] = @options unless @options.empty?
  hash
end