Class: Keyremac::Key
- Inherits:
-
Object
- Object
- Keyremac::Key
- Includes:
- Keyable
- Defined in:
- lib/keyremac/dump.rb,
lib/keyremac/key.rb
Overview
key
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#mods ⇒ Object
readonly
Returns the value of attribute mods.
Instance Method Summary collapse
- #add_mod(mod) ⇒ Object
- #dump(xml) ⇒ Object
-
#initialize(name) ⇒ Key
constructor
A new instance of Key.
- #to_key ⇒ Object
Methods included from Keyable
#add_rule, #consumer_key?, #overlaid, #to
Constructor Details
#initialize(name) ⇒ Key
Returns a new instance of Key.
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/keyremac/key.rb', line 72 def initialize(name) @mods = Set.new if key = SHIFT_TABLE[name] @code = SYMBOL_TABLE[key] || key self.shift else @code = SYMBOL_TABLE[name] || name end end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
66 67 68 |
# File 'lib/keyremac/key.rb', line 66 def code @code end |
#mods ⇒ Object (readonly)
Returns the value of attribute mods.
66 67 68 |
# File 'lib/keyremac/key.rb', line 66 def mods @mods end |
Instance Method Details
#add_mod(mod) ⇒ Object
83 84 85 86 |
# File 'lib/keyremac/key.rb', line 83 def add_mod(mod) @mods.add mod self end |
#dump(xml) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/keyremac/dump.rb', line 9 def dump(xml) if @mods.empty? "KeyCode::#{code.upcase}" else mods = @mods.to_a mods = mods.map { |mod| mod = mod.to_s if mod =~ /^VK_/ mod else "ModifierFlag::#{mod}" end } mods = mods.join(' | ') "KeyCode::#{code.upcase}, #{mods}" end end |
#to_key ⇒ Object
68 69 70 |
# File 'lib/keyremac/key.rb', line 68 def to_key self end |