Class: Terminitor::ItermCapture
- Inherits:
-
AbstractCapture
- Object
- AbstractCapture
- Terminitor::ItermCapture
- Includes:
- Appscript
- Defined in:
- lib/terminitor/capture/iterm_capture.rb
Overview
Captures terminal windows and tabs for Mac OS X
Constant Summary collapse
- OPTIONS_MASK =
Defines what options of window or tab to capture and how just in case we’ll need to get other properties
{ :window => { :bounds => "bounds" }, :tab => { :settings => "current_settings.name" } }
Instance Method Summary collapse
-
#capture_windows ⇒ Object
Returns settings of currently opened windows and tabs.
-
#initialize ⇒ ItermCapture
constructor
Initialize @terminal with Terminal.app, Load the Windows, store the Termfile Terminitor::MacCore.new(‘/path’).
-
#object_options(object) ⇒ Object
Returns hash of options of window or tab.
Methods inherited from AbstractCapture
Constructor Details
#initialize ⇒ ItermCapture
Initialize @terminal with Terminal.app, Load the Windows, store the Termfile Terminitor::MacCore.new(‘/path’)
19 20 21 |
# File 'lib/terminitor/capture/iterm_capture.rb', line 19 def initialize @terminal = app('iTerm.app') end |
Instance Method Details
#capture_windows ⇒ Object
Returns settings of currently opened windows and tabs.
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/terminitor/capture/iterm_capture.rb', line 24 def capture_windows windows = [] # for some reason terminal.windows[] contain duplicated elements @terminal.windows.get.uniq.each do |window| if window.visible.get tabs = window.tabs.get.inject([]) do |tabs, tab| tabs << {:options => (tab)} end windows << {:options => (window), :tabs => tabs} end end windows end |
#object_options(object) ⇒ Object
Returns hash of options of window or tab
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/terminitor/capture/iterm_capture.rb', line 39 def (object) = {} class_ = object.class_.get if class_ && OPTIONS_MASK[class_] OPTIONS_MASK[class_].each_pair do |option, getter| value = object.instance_eval(getter).get [option] = value end end end |