Class: Twterm::KeyMapper::AbstractKeyMapper
- Inherits:
-
Object
- Object
- Twterm::KeyMapper::AbstractKeyMapper
- Defined in:
- lib/twterm/key_mapper/abstract_key_mapper.rb
Direct Known Subclasses
AppKeyMapper, CursorKeyMapper, GeneralKeyMapper, StatusKeyMapper, TabKeyMapper
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(mappings) ⇒ AbstractKeyMapper
constructor
A new instance of AbstractKeyMapper.
Constructor Details
#initialize(mappings) ⇒ AbstractKeyMapper
Returns a new instance of AbstractKeyMapper.
8 9 10 11 12 13 14 15 16 |
# File 'lib/twterm/key_mapper/abstract_key_mapper.rb', line 8 def initialize(mappings) commands = self.class.commands mappings.keys.each do |k| raise NoSuchCommand.new(self.class.category, k) unless commands.include?(k) end @mappings = Hash[mappings.map { |k, v| [k, translate(v)] }] end |
Class Method Details
.commands ⇒ Object
46 47 48 |
# File 'lib/twterm/key_mapper/abstract_key_mapper.rb', line 46 def self.commands self::DEFAULT_MAPPINGS.keys end |
Instance Method Details
#[](key) ⇒ Object
18 19 20 21 |
# File 'lib/twterm/key_mapper/abstract_key_mapper.rb', line 18 def [](key) raise NoSuchCommand.new(self.class.category, key) unless @mappings.keys.include?(key) @mappings[key] end |