Class: Rbindkeys::WindowMatcher
- Inherits:
-
Object
- Object
- Rbindkeys::WindowMatcher
- Defined in:
- lib/rbindkeys.rb,
lib/rbindkeys/window_matcher.rb
Instance Attribute Summary collapse
-
#app_name ⇒ Object
readonly
Returns the value of attribute app_name.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(h) ⇒ WindowMatcher
constructor
A new instance of WindowMatcher.
- #match?(app_name, title) ⇒ Boolean
- #match_app?(app_name) ⇒ Boolean
- #match_title?(title) ⇒ Boolean
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_name ⇒ Object (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 |
#title ⇒ Object (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
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
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
30 31 32 |
# File 'lib/rbindkeys/window_matcher.rb', line 30 def match_title? title title and title.match @title end |