class TextEditor::Configuration::Mode

Attributes

name[R]

Public Class Methods

new(name, &block) click to toggle source
  # File lib/text_editor/configuration/mode.rb
6 def initialize(name, &block)
7   @name = name.to_sym
8   instance_eval(&block) if block
9 end

Public Instance Methods

bind(key, command = nil, *args, &block) click to toggle source
   # File lib/text_editor/configuration/mode.rb
11 def bind(key, command = nil, *args, &block)
12   keybindings[key] = [command || block, args]
13 end
keybindings() click to toggle source
   # File lib/text_editor/configuration/mode.rb
15 def keybindings
16   @keybindings ||= {}
17 end
resolve(key) click to toggle source
   # File lib/text_editor/configuration/mode.rb
19 def resolve(key)
20   keybindings.each do |keybinding, command|
21     return command if keybinding === key
22   end
23 
24   nil
25 end