public Method

IO.inspect

ios.inspect    string

Return a string describing this IO object.

Source Code

/*
* call-seq:
*   ios.inspect   => string
*
* Return a string describing this IO object.
*/

static VALUE
rb_io_inspect(obj)
   VALUE obj;
{
   OpenFile *fptr;
   char *buf, *cname, *st = "";
   long len;

   fptr = RFILE(rb_io_taint_check(obj))->fptr;
   if (!fptr || !fptr->path) return rb_any_to_s(obj);
   cname = rb_obj_classname(obj);
   len = strlen(cname) + strlen(fptr->path) + 5;
   if (!(fptr->f || fptr->f2)) {
       st = " (closed)";
       len += 9;
   }
   buf = ALLOCA_N(char, len);
   snprintf(buf, len, "#<%s:%s%s>", cname, fptr->path, st);
   return rb_str_new2(buf);
}
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.