Class: Hiiro::Tmux::Panes
- Inherits:
-
Object
- Object
- Hiiro::Tmux::Panes
- Includes:
- Enumerable
- Defined in:
- lib/hiiro/tmux/panes.rb
Instance Attribute Summary collapse
-
#panes ⇒ Object
readonly
Returns the value of attribute panes.
Class Method Summary collapse
Instance Method Summary collapse
- #active ⇒ Object
- #by_command(command) ⇒ Object
- #by_path(path) ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
- #find_by_id(id) ⇒ Object
- #find_by_index(index) ⇒ Object
- #ids ⇒ Object
- #in_session(session_name) ⇒ Object
- #in_window(window_id) ⇒ Object
-
#initialize(panes) ⇒ Panes
constructor
A new instance of Panes.
- #name_map ⇒ Object
- #size ⇒ Object (also: #count, #length)
- #targets ⇒ Object
Constructor Details
#initialize(panes) ⇒ Panes
Returns a new instance of Panes.
20 21 22 |
# File 'lib/hiiro/tmux/panes.rb', line 20 def initialize(panes) @panes = panes end |
Instance Attribute Details
#panes ⇒ Object (readonly)
Returns the value of attribute panes.
18 19 20 |
# File 'lib/hiiro/tmux/panes.rb', line 18 def panes @panes end |
Class Method Details
.fetch(target: nil, all: false) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/hiiro/tmux/panes.rb', line 6 def self.fetch(target: nil, all: false) args = ['tmux', 'list-panes', '-F', Pane::FORMAT] args << '-a' if all args += ['-t', target] if target && !all output = `#{args.shelljoin} 2>/dev/null` return new([]) if output.nil? || output.empty? panes = output.each_line.map { |line| Pane.from_format_line(line) }.compact new(panes) end |
Instance Method Details
#active ⇒ Object
44 45 46 |
# File 'lib/hiiro/tmux/panes.rb', line 44 def active self.class.new(panes.select(&:active?)) end |
#by_command(command) ⇒ Object
48 49 50 |
# File 'lib/hiiro/tmux/panes.rb', line 48 def by_command(command) self.class.new(panes.select { |p| p.command == command }) end |
#by_path(path) ⇒ Object
52 53 54 |
# File 'lib/hiiro/tmux/panes.rb', line 52 def by_path(path) self.class.new(panes.select { |p| p.path == path }) end |
#each(&block) ⇒ Object
24 25 26 |
# File 'lib/hiiro/tmux/panes.rb', line 24 def each(&block) panes.each(&block) end |
#empty? ⇒ Boolean
70 71 72 |
# File 'lib/hiiro/tmux/panes.rb', line 70 def empty? panes.empty? end |
#find_by_id(id) ⇒ Object
28 29 30 |
# File 'lib/hiiro/tmux/panes.rb', line 28 def find_by_id(id) panes.find { |p| p.id == id } end |
#find_by_index(index) ⇒ Object
32 33 34 |
# File 'lib/hiiro/tmux/panes.rb', line 32 def find_by_index(index) panes.find { |p| p.index == index } end |
#ids ⇒ Object
56 57 58 |
# File 'lib/hiiro/tmux/panes.rb', line 56 def ids panes.map(&:id) end |
#in_session(session_name) ⇒ Object
40 41 42 |
# File 'lib/hiiro/tmux/panes.rb', line 40 def in_session(session_name) self.class.new(panes.select { |p| p.session_name == session_name }) end |
#in_window(window_id) ⇒ Object
36 37 38 |
# File 'lib/hiiro/tmux/panes.rb', line 36 def in_window(window_id) self.class.new(panes.select { |p| p.window_id == window_id }) end |
#name_map ⇒ Object
64 65 66 67 68 |
# File 'lib/hiiro/tmux/panes.rb', line 64 def name_map panes.each_with_object({}) do |pane, h| h[pane.to_s] = pane.id end end |
#size ⇒ Object Also known as: count, length
74 75 76 |
# File 'lib/hiiro/tmux/panes.rb', line 74 def size panes.size end |
#targets ⇒ Object
60 61 62 |
# File 'lib/hiiro/tmux/panes.rb', line 60 def targets panes.map(&:target) end |