It seems like the code does not contain a solution to this exercise. I am taking the liberty of posting the snippet of solution as I understood your question for the purpose of verification:
define_method("#{name}=") do |val|
STDERR.puts "var name = #{ivar_name} and value = #{val}"
instance_variable_set(ivar_name,val)
end
Is that what you meant?
Bharat