class Basher::Handler
Constants
- ALPHABET
Attributes
bindings[R]
bindings[R]
Public Class Methods
bind(*keys, &action)
click to toggle source
# File lib/basher/handler.rb, line 8 def bind(*keys, &action) @bindings ||= {} keys.map(&:to_sym).each do |input| @bindings[input] ||= [] @bindings[input] << action end end
new(custom_bindings = {})
click to toggle source
# File lib/basher/handler.rb, line 19 def initialize(custom_bindings = {}) @bindings = self.class.bindings.merge(custom_bindings) end
Public Instance Methods
invoke(input)
click to toggle source
# File lib/basher/handler.rb, line 23 def invoke(input) bindings.fetch(input.to_sym, []).map do |b| b.call(input) end.last end
letter?(input)
click to toggle source
# File lib/basher/handler.rb, line 29 def letter?(input) return false if input.size != 1 input =~ /[[:alpha:]]/ end