class String
 orig_to_i = instance_method(:to_i)
 define_method(:to_i) do
  if /^-?\d+$/ =~ self 
   return orig_to_i.bind(self).call
  end
  return self
 end
end