Class: KeyboardMap::Event
- Inherits:
-
Object
- Object
- KeyboardMap::Event
- Defined in:
- lib/keyboard_map.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#modifiers ⇒ Object
readonly
Returns the value of attribute modifiers.
Instance Method Summary collapse
- #==(ev) ⇒ Object
-
#initialize(key, *modifiers, args: nil) ⇒ Event
constructor
A new instance of Event.
- #to_sym ⇒ Object
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
#args ⇒ Object (readonly)
Returns the value of attribute args.
11 12 13 |
# File 'lib/keyboard_map.rb', line 11 def args @args end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
11 12 13 |
# File 'lib/keyboard_map.rb', line 11 def key @key end |
#modifiers ⇒ Object (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_sym ⇒ Object
19 20 21 |
# File 'lib/keyboard_map.rb', line 19 def to_sym (modifiers.to_a.sort << key).join("_").to_sym end |