# File lib/quiz1/t/solutions/Bill Guindon/solitaire.rb, line 115 def process # does it look encrypted? 5 letter blocks all uppercase? looks_encrypted = @text.gsub(/[A-Z]{5}\s?/, '').empty? results = '' # prep the text for parsing. if looks_encrypted # strip off the blanks for consistency text = @text.gsub(/\s/, '') else # Discard any non A to Z characters, and uppercase all remaining text = @text.upcase.gsub!(/[^A-Z]/, '') # Split the message into five character groups, words, padding = word_count(text, 5) # using Xs to pad the last group text += padding end # parse it, and build up results. text.each_byte do |char| if looks_encrypted char -= next_key char += 26 if char < 65 else char += next_key char -= 26 if char > 90 end results += char.chr end return space_text(results, 5) end