Class: Rum::System::WindowMatcher
- Inherits:
-
Object
- Object
- Rum::System::WindowMatcher
show all
- Includes:
- Rum::System
- Defined in:
- lib/rum/windows/system.rb
Constant Summary
Constants included
from Rum::System
EM_GETSEL, EM_SETSEL, GWL_EXSTYLE, HWND_NOTOPMOST, HWND_TOPMOST, SC_CLOSE, SC_MAXIMIZE, SC_MINIMIZE, SC_RESTORE, SWP_NOMOVE, SWP_NOSIZE, SW_FORCEMINIMIZE, SW_HIDE, SW_MAX, SW_MAXIMIZE, SW_MINIMIZE, SW_NORMAL, SW_RESTORE, SW_SHOW, SW_SHOWDEFAULT, SW_SHOWMAXIMIZED, SW_SHOWMINIMIZED, SW_SHOWMINNOACTIVE, SW_SHOWNA, SW_SHOWNOACTIVATE, SW_SHOWNORMAL, ShellExecute, WM_COMMAND, WM_GETTEXT, WM_SYSCOMMAND, WS_EX_TOPMOST
Instance Attribute Summary collapse
Instance Method Summary
collapse
#active_window, #active_window_handles, #active_windows, #applescript, #applescript_quote_string, #c_string, def_api, #escape_shell_word, #get_selection, #input_box, #kill_task, #message_box, #send_key_event, #send_key_event_for_id, #send_keypress, #send_unicode_char, snake_case, #spawn_in_terminal, #start, #terminal_window
Constructor Details
#initialize(title = nil, class_name = nil) ⇒ WindowMatcher
Returns a new instance of WindowMatcher.
257
258
259
260
261
262
263
264
265
|
# File 'lib/rum/windows/system.rb', line 257
def initialize title=nil, class_name=nil
@specs = { title: title, class_name: class_name }
raise 'No specifications given.' unless @specs.values.any?
@specs.each do |spec, value|
if value.is_a? Regexp
@specs[spec] = Regexp.new(value.source, Regexp::IGNORECASE)
end
end
end
|
Instance Attribute Details
#specs ⇒ Object
Returns the value of attribute specs.
255
256
257
|
# File 'lib/rum/windows/system.rb', line 255
def specs
@specs
end
|
Instance Method Details
#[](spec) ⇒ Object
285
286
287
|
# File 'lib/rum/windows/system.rb', line 285
def [] spec
@specs[spec]
end
|
#active? ⇒ Boolean
277
278
279
|
# File 'lib/rum/windows/system.rb', line 277
def active?
matches? active_window
end
|
#comparison_method(obj) ⇒ Object
267
268
269
|
# File 'lib/rum/windows/system.rb', line 267
def comparison_method obj
if obj.is_a? Regexp then :=~ else :== end
end
|
#find ⇒ Object
289
290
291
292
293
294
295
296
|
# File 'lib/rum/windows/system.rb', line 289
def find
if @specs.values.any? { |spec| spec.is_a? Regexp }
active_windows.detect { |window| matches? window }
else
handle = find_window @specs[:class_name], @specs[:title]
Window.new(handle) unless handle == 0
end
end
|
#matches?(window) ⇒ Boolean
271
272
273
274
275
|
# File 'lib/rum/windows/system.rb', line 271
def matches? window
@specs.all? do |spec, value|
not value or value.send(comparison_method(value), window.send(spec))
end
end
|
#to_matcher ⇒ Object
281
282
283
|
# File 'lib/rum/windows/system.rb', line 281
def to_matcher
self
end
|