Class: ITerm2::Window
- Inherits:
-
Object
- Object
- ITerm2::Window
- Defined in:
- lib/iterm2/window.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #activate ⇒ Object
- #create_tab(profile_name: nil) ⇒ Object
-
#initialize(client:, id:) ⇒ Window
constructor
A new instance of Window.
- #tabs ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(client:, id:) ⇒ Window
Returns a new instance of Window.
7 8 9 10 |
# File 'lib/iterm2/window.rb', line 7 def initialize(client:, id:) @client = client @id = id end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/iterm2/window.rb', line 5 def client @client end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/iterm2/window.rb', line 5 def id @id end |
Instance Method Details
#activate ⇒ Object
12 13 14 |
# File 'lib/iterm2/window.rb', line 12 def activate client.activate_window(id) end |
#create_tab(profile_name: nil) ⇒ Object
21 22 23 24 |
# File 'lib/iterm2/window.rb', line 21 def create_tab(profile_name: nil) result = client.create_tab(window_id: id, profile_name: profile_name) Session.new(client: client, id: result[:session_id], window_id: result[:window_id], tab_id: result[:tab_id]) end |
#tabs ⇒ Object
16 17 18 19 |
# File 'lib/iterm2/window.rb', line 16 def tabs tab_ids = client.topology.select { |s| s[:window_id] == id }.map { |s| s[:tab_id] }.uniq tab_ids.map { |tab_id| Tab.new(client: client, id: tab_id, window_id: id) } end |
#to_h ⇒ Object
26 27 28 29 30 31 |
# File 'lib/iterm2/window.rb', line 26 def to_h { window_id: id, tabs: tabs.map(&:to_h) } end |