   (format "%s.const_set(\"%s\", Class.new do\n%s\nend.new)"
           (namespace->module (name (:ns env)))
           (clojure.string/upper-case (name (gensym "fn")))
-          (format "def invoke(*args)\n%s\nend" (-emit (first methods)))))
+          (indent
+            (format "def invoke(*args)\n%s\nend"
+                    (indent (-emit (first methods)))))))
 
 (defmethod -emit :local [{:keys [name] :as ast}]
   (str name))

  (let [arg-names (map :name fields)
        arglist (clojure.string/join ", " arg-names)
        ivar   #(format "@%s = %s" % %)
        attr-reader #(format "attr_reader :%s" %)
        ivars  (endl-separate (map ivar arg-names))
        attr-readers (endl-separate (map attr-reader arg-names))
        constructor (format "def initialize(%s)\n%s\nend" arglist ivars)
        body (endl-separate [attr-readers constructor])
        module (namespace->module (clojure.core/name ns))]
    (format "%s.const_set(\"%s\", Class.new do\n%s\nend)" module name body)))

(defmethod -emit :deftype [{:keys [name fields methods interfaces env] :as ast}]
  (emit-type (:ns env) name fields interfaces methods))

          (comma-separate (map -emit args))))

(defmethod -emit :if [{:keys [test then else] :as ast}]
  (let [else-expr (-emit else)]
    (if (= "" else-expr)
      (format "if %s\n%s\nend"
              (-emit test)
              (indent (-emit then)))
      (format "if %s\n%s\nelse\n%s\nend"
              (-emit test)
              (indent (-emit then))
              (indent else-expr)))))

(defmethod -emit :do [{:keys [statements ret env] :as ast}]
  (endl-separate (map -emit (conj (vec statements) ret))))
