Class: KeyboardMap::Event

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, *modifiers, args: nil) ⇒ Event

Returns a new instance of Event.



13
14
15
16
17
# File 'lib/keyboard_map.rb', line 13

def initialize(key, *modifiers, args: nil)
  @modifiers = Set[*modifiers.map(&:to_sym)]
  @key = key
  @args = args
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



11
12
13
# File 'lib/keyboard_map.rb', line 11

def args
  @args
end

#keyObject (readonly)

Returns the value of attribute key.



11
12
13
# File 'lib/keyboard_map.rb', line 11

def key
  @key
end

#modifiersObject (readonly)

Returns the value of attribute modifiers.



11
12
13
# File 'lib/keyboard_map.rb', line 11

def modifiers
  @modifiers
end

Instance Method Details

#==(ev) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/keyboard_map.rb', line 23

def ==(ev)
  case ev
  when Event
    return @modifiers == ev.modifiers && @key == ev.key
  when Symbol
    return self.to_sym == ev
  else
    return self.to_s == ev
  end
end

#to_symObject



19
20
21
# File 'lib/keyboard_map.rb', line 19

def to_sym
  (modifiers.to_a.sort << key).join("_").to_sym
end