title: Ruby - How to redefine class methods?
body: <p>How do I redefine a class method in ruby?</p>
  
  <p>say, for example, I want to redefine the method <code>File.basename("C:\abc.txt")</code> How do I do it?</p>
  
  <p>This doesn't work:</p>
  
  <pre><code>class File
    alias_method :old_bn, :basename
  
    def basename(*args)
      puts "herro wolrd!"
      old_bn(*args)
    end
  end
  </code></pre>
  
  <p>I get  <code>: undefined method 'basename' for class 'File' (NameError)</code></p>
  
  <p>btw, I'm using <code>JRuby</code></p>