class Sapristi::DefinitionProcessor
Attributes
wait_time[RW]
Public Class Methods
new(window_manager = WindowManager.new, process_manager = NewProcessWindowDetector.new)
click to toggle source
# File lib/sapristi/definition_processor.rb, line 5 def initialize(window_manager = WindowManager.new, process_manager = NewProcessWindowDetector.new) @window_manager = window_manager @process_manager = process_manager @wait_time = 30 end
Public Instance Methods
process_definition(definition)
click to toggle source
# File lib/sapristi/definition_processor.rb, line 13 def process_definition(definition) window = get_window definition.title, definition.command @window_manager.move_resize(window, [definition.x, definition.y, definition.width, definition.height]) @window_manager.to_workspace(window, definition.workspace) window end
Private Instance Methods
find_one_by_title(title)
click to toggle source
# File lib/sapristi/definition_processor.rb, line 31 def find_one_by_title(title) windows = @window_manager.find_window(/#{title}/) raise Error, "#{windows.size} windows have the same title: #{title}" if windows.size > 1 if windows.size.eql? 1 ::Sapristi.logger.info "Found existing window pid=#{windows[0].pid} title=#{windows[0].title}" end windows[0] end
get_window(title, command)
click to toggle source
# File lib/sapristi/definition_processor.rb, line 25 def get_window(title, command) (title && find_one_by_title(title)) || (command && @process_manager.detect_window_for_process(command, title, @wait_time)) || raise(Error, "Couldn't produce a window for this definition") end