--nextPart2997014.aKLpvyIufQ
Content-Type: text/plain;
  charsetso-8859-6"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Here's solution 2...

It now handles args, though somewhat poorly. If you know what you are doing 
you can get around this but it will win no points for user-friendlyness. Also 
got rid of the globals, I had to put @imethods within 'method_missing' 
itself, whether or not I used :attr_accessor

I was wrong about not printing one-liners, as I have found [1..array.size-2] 
will return the middle item of a three item array, so it works just fine. 
Ruby is smart(er than me)...

Here is irb session showing usage:
############################
> load 'quiz91.rb'
> class Test; include MethodMaker; end
> test = Test.new
=> #<Test:0xa7ae1f80>
> test.print_address(:number, :street)
No such method: print_address
Care to define print_address? (y/n) y
Enter method definition ([ctrl-d] when done):
puts "#{number} #{street}"
=> nil
irb> test.print_address("Four", "Pennsylvania Plaza")
Four Pennsylvania Plaza
=> nil
> test.print_address(350, "Fifth Avenue")
350 Fifth Avenue
=> nil
> test.print_name("Joe", "Ruby")
No such method: print_name 
Care to define print_name? (y/n) n
# bail out, or else 'Joe' and 'Ruby' will be the arg names 
NoMethodError: print_name
        from ./quiz91.rb:14:in `method_missing'
        from (irb):10
> test.print_name(:first,:last)
No such method: print_name
Care to define print_name? (y/n) y
Enter method definition ([ctrl-d] when done):
puts "#{first} #{last}"
=> nil
> test.print_name("Joe","Ruby")
Joe Ruby
...

Code:

module MethodMaker

  def method_missing(method_name, *args)
    @imethods = {}
    puts "No such method: #{method_name}"
    # It might be a simple typo...
    # so give a chance to bail out.
    print "Care to define #{method_name}? (y/n) "
    if $stdin.gets.chomp == "y" # 'y'
      prompt_method(method_name, args)
    else
      raise NoMethodError, "#{method_name}"
    end
  end

  def prompt_method(name, args=nil) 
    puts "Enter method definition ([ctrl-d] when done):"
    meth = "def #{name}(#{args ? args.join(", ") : ""})"
    while $stdin.gets
      meth += $_
    end
    meth += "end"
    meth = meth.gsub("\n",";")
    @imethods["#{name}"] = meth
    eval meth
  end

  def print_method(name)
    meth_Array = @imethods[name].split(";")
    puts meth_Array[0]
    meth_Array[1..meth_Array.size-2].each { |line| puts "  #{line}" }
    puts meth_Array[-1]
  end
end
#################################
-d
-- 
darren kirby :: Part of the problem since 1976 :: http://badcomputer.org
"...the number of UNIX installations has grown to 10, with more expected..."
- Dennis Ritchie and Ken Thompson, June 1972

--nextPart2997014.aKLpvyIufQ
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQBE6TPWwPD5Cr/3CJgRAlMxAKCAkGDrZxZY0RSq+aRrczMwiZJG+gCgvoaM
+elIYk5Nuutv8zqHG9bUFiokz
-----END PGP SIGNATURE-----

--nextPart2997014.aKLpvyIufQ--