title: Rubocop Offense: Use the return of the conditional for variable assignment and comparison
body: <p>My Rubocop offense is telling me I need to 'Use the return of the conditional for variable assignment and comparison'</p>
  
  <p>While I tried fixing it, it gave me another offense that my 'method line is too long'.</p>
  
  <p>I've tried refactoring to another method but my code broke.</p>
  
  <p>How do I shorten or refactor this code ?</p>
  
  <pre class="lang-rb prettyprint-override"><code>HSH = { 'a' =&gt; 'z', 'b' =&gt; 'y', 'c' =&gt; 'x', 'd' =&gt; 'w', 'e' =&gt; 'v', \
          'f' =&gt; 'u', 'g' =&gt; 't', 'h' =&gt; 's', \
          'i' =&gt; 'r', 'j' =&gt; 'q', 'k' =&gt; 'p', 'l' =&gt; 'o', 'm' =&gt; 'n' }.freeze
  
  
  def encoder(str)
    encoded_string = ''
    str.chars.each do |char|
      encoded_string = if HSH.key?(char) then encoded_string += HSH[char]
                       elsif HSH.invert.key?(char) then encoded_string += HSH.invert[char]
                       else encoded_string += char
                       end
    end
    encoded_string
  end
  </code></pre>
  
  <p>When I ran my test suite, everything was ok. </p>
  
  <p>But the rubocop offense gave me method line is too long.</p>