From a7b07118120f4d2fdb8213d5d83c1cbd80811858 Mon Sep 17 00:00:00 2001 From: elliottcable Date: Fri, 13 Mar 2009 15:36:44 -0400 Subject: [PATCH] Cleaned up some documentation on `Key`, and working harder to coerce `Key#initialize` into a symbol --- lib/nfoiled/key.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/nfoiled/key.rb b/lib/nfoiled/key.rb index e27d9fc..a14e374 100644 --- a/lib/nfoiled/key.rb +++ b/lib/nfoiled/key.rb @@ -1,7 +1,6 @@ module Nfoiled ## # This is the class of a single character of input received by Nfoiled. - # Handles modifiers for you. class Key Names = { 0 => :null, 1 => :soh, 2 => :stx, 3 => :etx, 4 => :eot, 5 => :enq, 6 => :ack, 7 => :bell, 8 => :backspace, @@ -25,9 +24,9 @@ module Nfoiled attr_reader :char ## - # Creates a new `Key`, including any modifiers. - def initialize symish - @char = symish.to_sym + # Creates a new `Key`. Input will be turned into a symbol if possible. + def initialize stringish + @char = stringish.respond_to?(:to_s) ? stringish.to_s.to_sym : stringish.to_sym end end end -- 2.11.4.GIT