Created
May 8, 2014 16:51
-
-
Save tompng/092cd158fb6b36da62ab to your computer and use it in GitHub Desktop.
Revisions
-
tompng created this gist
May 8, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ def get patterns loop do s = gets p = patterns.find{|p|p=~s} return [p, s] if p end end number = /\d+/ word = /[a-z]+/ pattern, text = get [number, word] case [pattern] when [number] puts text.to_i+1 when [word] puts text.upcase else puts 'what!?' end