title: Replacing letters in a string in Ruby
body: <p>I want to replace letters in a string using the following mapping:</p>
  
  <pre><code>letters = ("a".."z").to_a.zip(("b".."z").to_a.push("a"))
  [["a", "b"], ["b", "c"], ["c", "d"], ["d", "e"], ["e", "f"], ["f", "g"], ["g", "h"], ["h", "i"], ["i", "j"], ["j", "k"], ["k", "l"], ["l", "m"], ["m", "n"], ["n", "o"], ["o", "p"], ["p", "q"], ["q", "r"], ["r", "s"], ["s", "t"], ["t", "u"], ["u", "v"], ["v", "w"], ["w", "x"], ["x", "y"], ["y", "z"], ["z", "a"]]
  </code></pre>
  
  <p>From here I just want to replace all letters in a string so what I was trying is </p>
  
  <pre><code>str = "Somebody help I am on drugs and can't program! Just kidding."
  
  letters.each {|letter| str.gsub!(letter[0],letter[1])}
  
  puts str
  </code></pre>
  
  <p>returns </p>
  
  <pre><code>Saaaaaaa aaaa I aa aa aaaaa aaa aaa'a aaaaaaa! Jaaa aaaaaaa.
  </code></pre>
  
  <p>For some reason things that I want replaced are being replaced with an a and ignoring the mapping I created in the beginning. Anyone know whats going on? I got this idea from <a href="https://stackoverflow.com/questions/8132492/ruby-multiple-string-replacement">Ruby multiple string replacement</a> but for some reason this doesn't apply to my example.</p>