Module: Gdk::KeyMatcher
- Included in:
- EventKey
- Defined in:
- lib/hilfer/extensions.rb
Overview
mainly for testing Gdk::EventKey, cos they’re hard to instantiate
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/hilfer/extensions.rb', line 44
def method_missing( meth, *args, &block )
if meth.to_s[-1] == "?"[0]
possible_key = meth.to_s[0..-2]
if possible_key.size == 1
key_name == possible_key || key_name == possible_key.upcase
else
key_name == possible_key.capitalize
end
else
super
end
end
|
Instance Method Details
#=~(arg) ⇒ Object
40
41
42
|
# File 'lib/hilfer/extensions.rb', line 40
def =~( arg )
match( arg )
end
|
#gdk_symbol ⇒ Object
22
23
24
|
# File 'lib/hilfer/extensions.rb', line 22
def gdk_symbol
Gdk::Keyval.symbol( keyval )
end
|
#key_name ⇒ Object
18
19
20
|
# File 'lib/hilfer/extensions.rb', line 18
def key_name
self.gdk_symbol[4..-1]
end
|
#match(*args) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/hilfer/extensions.rb', line 26
def match( *args )
bools = args.map do |arg|
case arg
when String
key_name == arg
when Regexp
!arg.match( key_name ).nil?
when Symbol
arg.to_s.downcase == key_name.downcase
end
end
return bools.include?( true )
end
|