module MovingsignApi::PrettyKeyable::ClassMethods

Public Instance Methods

codes() click to toggle source
# File lib/movingsign_api/commands/internal/pretty_keyable.rb, line 45
def codes
  class_variable_get(:@@CODES)
end
keys() click to toggle source
# File lib/movingsign_api/commands/internal/pretty_keyable.rb, line 41
def keys
  class_variable_get(:@@KEYS)
end
parse_to_key(input) click to toggle source
# File lib/movingsign_api/commands/internal/pretty_keyable.rb, line 33
def parse_to_key(input)
  if index = (keys.index(input) || codes.index(input))
    keys[index]
  else
    nil
  end
end
register(key, code) click to toggle source

registers the specified key and code pair as synonymous

# File lib/movingsign_api/commands/internal/pretty_keyable.rb, line 24
def register(key, code)
  keys << key
  codes << code

  define_singleton_method(key) do
    key
  end
end