Class: Rbindkeys::WindowMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/rbindkeys.rb,
lib/rbindkeys/window_matcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(h) ⇒ WindowMatcher

Returns a new instance of WindowMatcher.



11
12
13
14
15
16
17
18
19
# File 'lib/rbindkeys/window_matcher.rb', line 11

def initialize h
  @app_name = (h[:class] or h[:app_name] or h[:app_class])
  @title = (h[:title] or h[:name])

  if not @app_name.nil? and not @title.nil?
    raise ArgumentError, 'expect to be given :class, :app_name,'+
      ' :app_class, :title or :name '
  end
end

Instance Attribute Details

#app_nameObject (readonly)

Returns the value of attribute app_name.



9
10
11
# File 'lib/rbindkeys/window_matcher.rb', line 9

def app_name
  @app_name
end

#titleObject (readonly)

Returns the value of attribute title.



9
10
11
# File 'lib/rbindkeys/window_matcher.rb', line 9

def title
  @title
end

Instance Method Details

#match?(app_name, title) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
# File 'lib/rbindkeys/window_matcher.rb', line 21

def match? app_name, title
  (@app_name.nil? or match_app?(app_name)) and
    (@title.nil? or match_title?(title))
end

#match_app?(app_name) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/rbindkeys/window_matcher.rb', line 26

def match_app? app_name
  app_name and app_name.match @app_name
end

#match_title?(title) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/rbindkeys/window_matcher.rb', line 30

def match_title? title
  title and title.match @title
end