title: How to read characters from a text file, then store them into a hash in Ruby
body: <p>I am working on an assignment, and can't figure it out. We have to first parse a text file, and then feed the results into a hash.  I have done this:</p>
  
  <pre><code>    code = File.open(WORKING_DIR + '/code.txt','r')
      char_count = {'a' =&gt; 0,'b' =&gt; 0,'c' =&gt; 0,'d' =&gt; 0,'e' =&gt; 0,'f' =&gt; 0,'g' =&gt; 0,'h' =&gt; 0,'i' =&gt; 0,
                     'j' =&gt; 0,'k' =&gt; 0,'l' =&gt; 0,'m' =&gt; 0,'n' =&gt; 0,'o' =&gt; 0,'p' =&gt; 0,'q' =&gt; 0,'r' =&gt; 0,
                     's' =&gt; 0,'t' =&gt; 0,'u' =&gt; 0,'v' =&gt; 0,'w' =&gt; 0,'x' =&gt; 0,'y' =&gt; 0,'z' =&gt; 0
                     }
  # Step through each line in the file.
  code.readlines.each do |line|
  
      # Print each character of this particular line.
      line.split('').each do
          |ch| 
              char_count.has_key?('ch')
                  char_count['ch'] +=1        
             end
  </code></pre>
  
  <p>My line of thinking: open the file to a variable named code
  read the individual lines
  break the lines into each character.
  I know this works, I can puts out the characters to screen.
  Now I need to feed the characters into the hash, and it isn't working.  I am struggling with the syntax (at least) and basic concepts (at most). I only want the alphabet characters, not the punctuation, etc. from the file.</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Thanks.</p>