Class: Rkremap::App

Inherits:
Object
  • Object
show all
Defined in:
lib/rkremap.rb

Instance Method Summary collapse

Constructor Details

#initialize(winattr) ⇒ App

Returns a new instance of App.

Parameters:



185
186
187
188
# File 'lib/rkremap.rb', line 185

def initialize(winattr)
  @winattr = winattr
  @win = winattr.focus_win
end

Instance Method Details

#class_nameString?

Returns:

  • (String, nil)


191
192
193
# File 'lib/rkremap.rb', line 191

def class_name
  @winattr.class_name(@win) if @winattr && @win
end

#match?(app) ⇒ Boolean

Parameters:

  • app (Array, Hash, String, Regexp)

Returns:

  • (Boolean)


202
203
204
205
206
207
208
# File 'lib/rkremap.rb', line 202

def match?(app)
  [app].flatten.each do |a|
    a = {class_name: a, title: a} unless a.is_a? Hash
    return true if match_sub(a[:class_name], class_name) || match_sub(a[:title], title)
  end
  false
end

#match_sub(a, b) ⇒ Object

Parameters:

  • a (String, Regexp)
  • b (String)


212
213
214
215
216
217
218
219
220
221
# File 'lib/rkremap.rb', line 212

def match_sub(a, b)
  case a
  when String
    a == b
  when Regexp
    a =~ b
  else
    false
  end
end

#titleString?

Returns:

  • (String, nil)


196
197
198
# File 'lib/rkremap.rb', line 196

def title
  @winattr.app_title(@win) if @winattr && @win
end