Yonik's comment lead me to discover that "irb" is the interactive ruby shell (who knew!) which lead me to spend 20 minutes banging my head against my desk (and google) attempting to find literals or constants that express NaN or Infinity.
I can not fathom the existence a language written in this millennium that understands the concept of NaN but has no literal way for you to express NaN without doing a computation. I would say "i've lost all respect for Ruby", but since i didn't really know enough about ruby to respest it before, let me just say "i've lost the ability to gain respect for Ruby in the future".
I can't believe i'm saying this, but: would it be worth while for the RubyResponseWriter to output code that declares variables for NaN, Infinite and -Infinite and only does those 3 computations once, instead of each time they occur? (i'm assuming that if one document has a NaN value for a field value, then other docs will probably have a NaN value).