Class: Xkbcommon::Key
- Inherits:
-
Object
- Object
- Xkbcommon::Key
- Defined in:
- lib/xkbcommon/key.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#keymap ⇒ Object
readonly
Returns the value of attribute keymap.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#scan_code ⇒ Object
readonly
Returns the value of attribute scan_code.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(keymap, code) ⇒ Key
constructor
A new instance of Key.
- #inspect ⇒ Object
Constructor Details
#initialize(keymap, code) ⇒ Key
Returns a new instance of Key.
25 26 27 28 29 30 |
# File 'lib/xkbcommon/key.rb', line 25 def initialize(keymap, code) @keymap = keymap @code = code @scan_code = code - 8 # about offset 8: http://xkbcommon.org/doc/current/xkbcommon_8h.html#ac29aee92124c08d1953910ab28ee1997 @name = self.class.code_to_name(@scan_code) end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
32 33 34 |
# File 'lib/xkbcommon/key.rb', line 32 def code @code end |
#keymap ⇒ Object (readonly)
Returns the value of attribute keymap.
32 33 34 |
# File 'lib/xkbcommon/key.rb', line 32 def keymap @keymap end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
32 33 34 |
# File 'lib/xkbcommon/key.rb', line 32 def name @name end |
#scan_code ⇒ Object (readonly)
Returns the value of attribute scan_code.
32 33 34 |
# File 'lib/xkbcommon/key.rb', line 32 def scan_code @scan_code end |
Class Method Details
.code_to_name(code) ⇒ Object
6 7 8 |
# File 'lib/xkbcommon/key.rb', line 6 def code_to_name(code) codes_to_names[code] end |
Instance Method Details
#inspect ⇒ Object
34 35 36 |
# File 'lib/xkbcommon/key.rb', line 34 def inspect "#<#{self.class.name}:0x#{'%014x' % __id__} @code=#{code} @name=#{name.inspect}>" end |