title: How to understand this code piece in ruby?
body: <p>In Metaprogramming Ruby I saw this code</p>
  
  <pre><code>class String
    def to_alphanumeric
      gsub /[^\w\s]/, ''
    end
  end
  </code></pre>
  
  <p>Here it adds a method to_alphanumeric, which substitutes punctuations with whitespace, to the standard class String. What confuses me is, since we do not specify which object gsub works on, how does Ruby know here we actually mean gsub works on the String obj itself instead of something else? Or put it in another way, does Ruby automatically rewrite it as self.gsub? </p>