title: Automatic ruby folding in vim
body: <p>Is there a way that I can setup vim to automatically fold ruby source files, but only fold at the method level regardless of the level that they are defined? </p>
  
  <p>So it will fold when I have:</p>
  
  <pre><code>class MyClass
    def method
      ...
    end
  end
  </code></pre>
  
  <p>but also when I have:</p>
  
  <pre><code>module FirstModule
    module SecondModule
      class MyClass
        def method
          ...
        end
      end
    end
  end
  </code></pre>
  
  <p>I've experimented with foldmethod=syntax and various fold levels but it doesn't take into account the depth where the method is defined.</p>
  
  <p>Also I don't want nothing inside the method to get folded (if blocks, each blocks, etc).</p>
  
  <p>I think foldmethod=expr would be my best bet, but I haven't manage to figure out how fold expressions work, and the help in vim hasn't been very enlightening.</p>