# \[QUIZ\] QA Prototype (#91)

**URL:** <https://www.ruby-forum.com/t/quiz-qa-prototype-91/65910>\
**Category:** Ruby\
**Created:** [August 22, 2006, 10:53am UTC](https://www.ruby-forum.com/t/quiz-qa-prototype-91/65910 "2006-08-22T10:53:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lock\_Stephen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/6f9a4e/32.png) [@Lock\_Stephen](https://www.ruby-forum.com/u/Lock_Stephen)\
**Post date:** [August 22, 2006, 10:53am UTC](https://www.ruby-forum.com/t/quiz-qa-prototype-91/65910/1 "2006-08-22T10:53:30Z")

</div>

My attempt - surprisingly short. Really annoying to test because every  
time you have a typo on a method name it offers to dynamically create  
the method for you!

I imagine it’s nothing too far removed from how everybody else is doing  
it.

module QAPrototype  
@@methods = Hash.new  
def method\_missing( name, \*args )  
puts “Undefined method " + self.class.to\_s + “.” +  
name.to\_s  
puts “How do you want me to handle this method? (end  
with a newline)”  
$stdout.flush  
method = Array.new  
begin  
line = gets  
method \<\< line  
end until line.eql?(”\n")  
@@methods[name]=method  
self.class.instance\_eval do  
define\_method(name) { eval(method.join) }  
end  
puts “OK”  
end

```
def print_defined_methods
	@@methods.each_pair { |key, value|
		puts key.to_s + ":"
		puts value
	}
end

```

End

I found an interesting thing when trying this in the runtime in SciTE -  
for some reason when ‘gets’ reads in a line, if you made a mistake  
whilst typing and backspaced to delete some text and re-write it, then  
the string that ‘gets’ returns includes the deleted text. Anyone know  
why this might be?

Stephen

* * *

DISCLAIMER  
The information contained in this e-mail is confidential and is intended  
for the recipient only.  
If you have received it in error, please notify us immediately by reply  
e-mail and then delete it from your system. Please do not copy it or  
use it for any other purposes, or disclose the content of the e-mail  
to any other person or store or copy the information in any medium.  
The views contained in this e-mail are those of the author and not  
necessarily those of Admenta UK Group.

* * *

---

<div class="post-metadata">

**Author:** ![Lock\_Stephen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/6f9a4e/32.png) [@Lock\_Stephen](https://www.ruby-forum.com/u/Lock_Stephen)\
**Post date:** [August 22, 2006, 3:04pm UTC](https://www.ruby-forum.com/t/quiz-qa-prototype-91/65910/2 "2006-08-22T15:04:15Z")

</div>

On Aug 22, 2006, at 3:52 AM, Lock Stephen wrote:

> End

Is that a typo? Should be “end” I assume.

James Edward G. II
