I wondered what gives you optimalization
if (foo.instance_of?(bar)) foo =foo.to_bar; 
istead foo=barconvert(foo);
So I did quick benchmark
require 'benchmark'
Benchmark.bm{|b|
b.report{1000000.times{|i|Fixnum;i.to_i}}
b.report{1000000.times{|i|i.instance_of?(Fixnum)}}
}
And first was bit better. 
I put Fixnum in first test because without took first test 0.6s and second 0.8s
So it makes your code slower.
Benchmark in C would show same.