Class: KeyEvent
- Inherits:
-
Object
- Object
- KeyEvent
- Defined in:
- lib/vtparser/keymap.rb
Overview
Logic taken from vidarh/keyboard_map gem
github.com/vidarh/keyboard_map
See examples/keymap.rb for usage
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
- #==(other) ⇒ Object
-
#initialize(key, *modifiers, args: nil) ⇒ KeyEvent
constructor
A new instance of KeyEvent.
- #to_s ⇒ Object
- #to_sym ⇒ Object
Constructor Details
#initialize(key, *modifiers, args: nil) ⇒ KeyEvent
Returns a new instance of KeyEvent.
14 15 16 17 18 |
# File 'lib/vtparser/keymap.rb', line 14 def initialize(key, *modifiers, args: nil) @key = key @args = args @modifiers = modifiers.map(&:to_sym).to_set end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
12 13 14 |
# File 'lib/vtparser/keymap.rb', line 12 def args @args end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
12 13 14 |
# File 'lib/vtparser/keymap.rb', line 12 def key @key end |
#modifiers ⇒ Object (readonly)
Returns the value of attribute modifiers.
12 13 14 |
# File 'lib/vtparser/keymap.rb', line 12 def modifiers @modifiers end |
Instance Method Details
#==(other) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/vtparser/keymap.rb', line 28 def ==(other) case other when KeyEvent self.modifiers == other.modifiers && self.key == other.key when Symbol self.to_sym == other else self.to_s == other end end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/vtparser/keymap.rb', line 20 def to_s (modifiers.to_a.sort << key).join('_') end |
#to_sym ⇒ Object
24 25 26 |
# File 'lib/vtparser/keymap.rb', line 24 def to_sym to_s.to_sym end |