Class: ITerm2::Tab
- Inherits:
-
Object
- Object
- ITerm2::Tab
- Defined in:
- lib/iterm2/tab.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#window_id ⇒ Object
readonly
Returns the value of attribute window_id.
Instance Method Summary collapse
- #activate(order_window_front: true) ⇒ Object
- #close(force: false) ⇒ Object
-
#initialize(client:, id:, window_id:) ⇒ Tab
constructor
A new instance of Tab.
- #primary_session ⇒ Object
- #sessions ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(client:, id:, window_id:) ⇒ Tab
Returns a new instance of Tab.
7 8 9 10 11 |
# File 'lib/iterm2/tab.rb', line 7 def initialize(client:, id:, window_id:) @client = client @id = id @window_id = window_id end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/iterm2/tab.rb', line 5 def client @client end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/iterm2/tab.rb', line 5 def id @id end |
#window_id ⇒ Object (readonly)
Returns the value of attribute window_id.
5 6 7 |
# File 'lib/iterm2/tab.rb', line 5 def window_id @window_id end |
Instance Method Details
#activate(order_window_front: true) ⇒ Object
13 14 15 |
# File 'lib/iterm2/tab.rb', line 13 def activate(order_window_front: true) client.activate_tab(id, order_window_front: order_window_front) end |
#close(force: false) ⇒ Object
27 28 29 |
# File 'lib/iterm2/tab.rb', line 27 def close(force: false) client.close_tab(id, force: force) end |
#primary_session ⇒ Object
23 24 25 |
# File 'lib/iterm2/tab.rb', line 23 def primary_session sessions.first end |
#sessions ⇒ Object
17 18 19 20 21 |
# File 'lib/iterm2/tab.rb', line 17 def sessions client.topology .select { |s| s[:tab_id] == id && s[:window_id] == window_id } .map { |s| Session.new(client: client, id: s[:session_id], window_id: s[:window_id], tab_id: s[:tab_id], title: s[:title]) } end |
#to_h ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/iterm2/tab.rb', line 31 def to_h { window_id: window_id, tab_id: id, sessions: sessions.map(&:to_h) } end |