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:



182
183
184
185
# File 'lib/rkremap.rb', line 182

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

Instance Method Details

#class_nameString?

Returns:

  • (String, nil)


188
189
190
# File 'lib/rkremap.rb', line 188

def class_name
  @winattr.app_win(@win)[2] if @winattr && @win
end

#match?(app) ⇒ Boolean

Parameters:

  • app (Array, Hash, String, Regexp)

Returns:

  • (Boolean)


199
200
201
202
203
204
205
# File 'lib/rkremap.rb', line 199

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)


209
210
211
212
213
214
215
216
217
218
# File 'lib/rkremap.rb', line 209

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

#titleString?

Returns:

  • (String, nil)


193
194
195
# File 'lib/rkremap.rb', line 193

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