If instead of hiding "end"s using a special font, which anyway leaves
their corresponding lines there, you prefer to remove everything so

   def foo
     # ...
       end
     end
   end

   def bar

becomes in the buffer

   def foo
     # ...

   def bar

here's a bit of Elisp I've just hacked up based on some code Xavier Decoret
posted to news:comp.emacs a few years ago. The intended use is to toggle
their visibility just pressing, say, <f7> when you are in Ruby mode:

(defvar ruby-ends-hide-regexp-overlays nil "")
(make-variable-buffer-local 'ruby-ends-hide-regexp-overlays)

(defun hide-ruby-ends ()
  "Hide Ruby end keywords."
  (interactive)
  (let ((regexp "^\\(?:[ \\t]*end\n\\)+"))
    (save-excursion
      (goto-char (point-min))
      (while (and (< (point) (point-max))
                  (re-search-forward regexp nil t))
        (let ((overlay (make-overlay (match-beginning 0) (match-end 0))))
          (overlay-put overlay 'invisible 't)
          (overlay-put overlay 'intangible 't)
          (setq ruby-ends-hide-regexp-overlays
                (cons overlay ruby-ends-hide-regexp-overlays)))))))

(defun unhide-ruby-ends ()
  "Unhide Ruby end keywords."
  (interactive)
  ;; remove all overlays in the buffer
  (while (not (null ruby-ends-hide-regexp-overlays))
    (delete-overlay (car ruby-ends-hide-regexp-overlays))
    (setq ruby-ends-hide-regexp-overlays (cdr ruby-ends-hide-regexp-overlays))))

(defvar ruby-ends-are-hidden nil "")
(make-variable-buffer-local 'ruby-ends-are-hidden)

(defun toggle-ruby-ends ()
  "Hide/unhide Ruby end keywords."
  (interactive)
  (cond (ruby-ends-are-hidden (unhide-ruby-ends)
                              (setq ruby-ends-are-hidden nil))
        (t (hide-ruby-ends)
           (setq ruby-ends-are-hidden t))))

(require 'ruby-mode)
(define-key ruby-mode-map (kbd "<f7>") 'toggle-ruby-ends)

Unfortunately it does not work well for editing (I don't know whether
that can be fixed), and assumes any "end" found in a line with optional
leading whitespace has to be hidden.

-- fxn