title: Ruby syntax error: unexpected $end, expecting keyword_end
body: <p>I am supposed to:</p>
  
  <ul>
  <li>Capitalize the first letter of string.</li>
  <li>Capitalize every word except articles (<code>the</code>, <code>a</code>, <code>an</code>), conjunctions (<code>and</code>), and prepositions (<code>in</code>).</li>
  <li>Capitalize <code>i</code> (as in <code>"I am male."</code>).</li>
  <li>Specify the first word of a string (I actually have no idea what this means. I'm trying to  run the spec file to test other functions).</li>
  </ul>
  
  <p>Here's my code:</p>
  
  <pre><code>class Book
    def initialize(string)
      title(string)
    end
    def title(string)
      arts_conjs_preps = %w{ a an the and
                             but or nor for
                             yet so although
                             because since
                             unless despite
                             in to
                             }
      array = string.downcase.split
      array.each do |word|
          if (word == array[0] || word == "i") then word = word.capitalize
          if arts_conjs_preps !include?(word) then word = word.capitalize
      end
      puts array.join(' ')
    end
  end
  
  puts Book.new("inferno")
  </code></pre>
  
  <p>Ruby says I'm messing up at:</p>
  
  <pre><code>puts Book.new("inferno") &lt;--(right after the last line of code) 
  </code></pre>
  
  <p>I get exactly the same error message with this test code:</p>
  
  <pre><code>def title(string)
      array = string.downcase.split
      array.each do |word|
          if word == array[0] then word = word.capitalize     
      end
    array.join(' ')
  end
  
  puts title("dante's inferno")
  </code></pre>
  
  <p>The only other Stack Overflow thread regarding this particular syntax error that did not suggest trailing or missing <code>end</code>s or <code>.</code>s as the root of the problem is <a href="https://stackoverflow.com/questions/8061789/unexpected-keyword-end-expecting-end-syntaxerror?rq=1">here</a>. The last comment recommends deleting and recreating the gemset, Which sounds scary. And I'm not sure how to do.</p>
  
  <p>Any thoughts? Simple solution? Resources to help?</p>
  
  <p><strong>Solution</strong></p>
  
  <pre><code>class Book
      def initialize(string)
          title(string)
      end
  
      def title(string)
      arts_conjs_preps = %w{ a an the and
                         but or nor for
                         yet so although
                         because since
                         unless despite
                         of in to
                                 }
      array = string.downcase.split
      title = array.map do |word|
            if (word == array[0] || word == "i") || !arts_conjs_preps.include?(word)  
              word = word.capitalize 
            else
              word
            end
          end
        puts title.join(' ')
      end
  end
  
  Book.new("dante's the inferno")
  </code></pre>