123456789_123456789_123456789_123456789_123456789_

Top Level Namespace

Constant Summary

Class Attribute Summary

Class Method Summary

Class Attribute Details

$! (readonly)

[ GitHub ]

  
# File 'eval.c', line 1818

static VALUE
errinfo_getter(ID id)
{
    return get_errinfo();
}

Process.pidInteger (readonly)

Returns the process id of this process. Not available on all platforms.

Process.pid   #=> 27415
[ GitHub ]

  
# File 'process.c', line 460

static VALUE
get_pid(void)
{
    return PIDT2NUM(getpid());
}

$& (readonly)

[ GitHub ]

  
# File 're.c', line 1837

static VALUE
last_match_getter(void)
{
    return rb_reg_last_match(rb_backref_get());
}

$' (readonly)

[ GitHub ]

  
# File 're.c', line 1849

static VALUE
postmatch_getter(void)
{
    return rb_reg_match_post(rb_backref_get());
}

$*(*var) (readonly)

[ GitHub ]

  
# File 'io.c', line 12760

static VALUE
argf_argv_getter(ID id, VALUE *var)
{
    return argf_argv(*var);
}

$+ (readonly)

[ GitHub ]

  
# File 're.c', line 1855

static VALUE
last_paren_match_getter(void)
{
    return rb_reg_match_last(rb_backref_get());
}

$, (rw)

[ GitHub ]

  
# File 'io.c', line 13113

rb_define_hooked_variable("$,", &rb_output_fs, 0, rb_str_setter);

$-0 (rw)

Alias for $/.

[ GitHub ]

  
# File 'io.c', line 13120

rb_define_hooked_variable("$-0", &rb_rs, 0, rb_str_setter);

$-d (readonly)

Alias for $DEBUG.

[ GitHub ]

  
# File 'ruby.c', line 2322

rb_define_variable("$-d", &ruby_debug);

$-F (rw)

Alias for $;.

[ GitHub ]

  
# File 'string.c', line 11212

rb_define_hooked_variable("$-F", &rb_fs, 0, rb_fs_setter);

$-i(*var) (rw)

[ GitHub ]

  
# File 'io.c', line 12678

static VALUE
opt_i_get(ID id, VALUE *var)
{
    return argf_inplace_mode_get(*var);
}

$-K (rw)

Alias for $KCODE.

$-v (rw)

Alias for $VERBOSE.

[ GitHub ]

  
# File 'ruby.c', line 2318

rb_define_hooked_variable("$-v", &ruby_verbose, 0, verbose_setter);

$-W() (readonly)

[ GitHub ]

  
# File 'ruby.c', line 2297

static VALUE
opt_W_getter(ID id, void *data)
{
    VALUE *variable = data;
    switch (*variable) {
      case Qnil:
	return INT2FIX(0);
      case Qfalse:
	return INT2FIX(1);
      case Qtrue:
	return INT2FIX(2);
      default:
	return Qnil;
    }
}

$-w (rw)

Alias for $VERBOSE.

[ GitHub ]

  
# File 'ruby.c', line 2319

rb_define_hooked_variable("$-w", &ruby_verbose, 0, verbose_setter);

$.(*var) (rw)

[ GitHub ]

  
# File 'io.c', line 8758

static VALUE
argf_lineno_getter(ID id, VALUE *var)
{
    VALUE argf = *var;
    return INT2FIX(ARGF.last_lineno);
}

$/ (rw) Also known as: ::$-0

[ GitHub ]

  
# File 'io.c', line 13119

rb_define_hooked_variable("$/", &rb_rs, 0, rb_str_setter);

$0 (rw) Also known as: ::$PROGRAM_NAME

[ GitHub ]

  
# File 'ruby.c', line 2324

rb_define_hooked_variable("$0", &rb_progname, 0, set_arg0);

$; (rw) Also known as: ::$-F

[ GitHub ]

  
# File 'string.c', line 11211

rb_define_hooked_variable("$;", &rb_fs, 0, rb_fs_setter);

$< (readonly)

[ GitHub ]

  
# File 'io.c', line 13323

rb_define_readonly_variable("$<", &argf);

$= (rw)

[ GitHub ]

  
# File 're.c', line 3945

static VALUE
ignorecase_getter(void)
{
    rb_warn("variable $= is no longer effective");
    return Qfalse;
}

$> (rw)

Alias for $stdout.

[ GitHub ]

  
# File 'io.c', line 13235

rb_define_hooked_variable("$>", &rb_stdout, 0, stdout_setter);

$@ (rw)

[ GitHub ]

  
# File 'eval.c', line 1853

static VALUE
errat_getter(ID id)
{
    VALUE err = get_errinfo();
    if (!NIL_P(err)) {
	return rb_get_backtrace(err);
    }
    else {
	return Qnil;
    }
}

$\ (readonly) Also known as: ::$LOADED_FEATURES

[ GitHub ]

  
# File 'load.c', line 151

static VALUE
get_loaded_features(void)
{
    return GET_VM()->loaded_features;
}

$\\ (rw)

[ GitHub ]

  
# File 'io.c', line 13121

rb_define_hooked_variable("$\\", &rb_output_rs, 0, rb_str_setter);

$_ (rw)

[ GitHub ]

$` (readonly)

[ GitHub ]

  
# File 're.c', line 1843

static VALUE
prematch_getter(void)
{
    return rb_reg_match_pre(rb_backref_get());
}

$DEBUG (readonly) Also known as: ::$-d

[ GitHub ]

  
# File 'ruby.c', line 2321

rb_define_variable("$DEBUG", &ruby_debug);

$FILENAME(*var) (readonly)

[ GitHub ]

  
# File 'io.c', line 12511

static VALUE
argf_filename_getter(ID id, VALUE *var)
{
    return argf_filename(*var);
}

$find_time_numguess (readonly)

[ GitHub ]

  
# File 'time.c', line 3019

static VALUE find_time_numguess_getter(void)
{
    return ULL2NUM(find_time_numguess);
}

$KCODE (rw) Also known as: ::$-K

[ GitHub ]

  
# File 're.c', line 3932

static VALUE
kcode_getter(void)
{
    rb_warn("variable $KCODE is no longer effective");
    return Qnil;
}

$LOADED_FEATURES (readonly)

Alias for $.

$PROGRAM_NAME (rw)

Alias for $0.

[ GitHub ]

  
# File 'ruby.c', line 2325

rb_define_hooked_variable("$PROGRAM_NAME", &rb_progname, 0, set_arg0);

$SAFE (rw)

[ GitHub ]

  
# File 'safe.c', line 68

static VALUE
safe_getter(void)
{
    return INT2NUM(rb_safe_level());
}

$stderr (rw)

[ GitHub ]

  
# File 'io.c', line 13233

rb_define_hooked_variable("$stderr", &rb_stderr, 0, stdout_setter);

$stdin (readonly)

[ GitHub ]

  
# File 'io.c', line 13229

rb_define_variable("$stdin", &rb_stdin);

$stdout (rw) Also known as: ::$>

[ GitHub ]

  
# File 'io.c', line 13231

rb_define_hooked_variable("$stdout", &rb_stdout, 0, stdout_setter);

$VERBOSE (rw) Also known as: ::$-v, ::$-w

! Defines built-in variables

[ GitHub ]

  
# File 'ruby.c', line 2317

rb_define_hooked_variable("$VERBOSE", &ruby_verbose, 0, verbose_setter);

$VERBOSE= (rw) Also known as: ::$-v=, ::$-w=

! Defines built-in variables

[ GitHub ]

  
# File 'ruby.c', line 2290

static void
verbose_setter(VALUE val, ID id, void *data)
{
    VALUE *variable = data;
    *variable = RTEST(val) ? Qtrue : val;
}

$~ (rw)

[ GitHub ]

  
# File 're.c', line 3958

static VALUE
match_getter(void)
{
    VALUE match = rb_backref_get();

    if (NIL_P(match)) return Qnil;
    rb_match_busy(match);
    return match;
}

Class Method Details

$?Boolean

::Process::Status encapsulates the information on the status of a running or terminated system process. The built-in variable $? is either nil or a ::Process::Status object.

fork { exit 99 }   #=> 26557
Process.wait       #=> 26557
$?.class           #=> Process::Status
$?.to_i            #=> 25344
$? >> 8            #=> 99
$?.stopped?        #=> false
$?.exited?         #=> true
$?.exitstatus      #=> 99

Posix systems record information on processes using a 16-bit integer. The lower bits record the process status (stopped, exited, signaled) and the upper bits possibly contain additional information (for example the program’s return code in the case of exited processes). Pre Ruby 1.8, these bits were exposed directly to the Ruby program. Ruby now encapsulates these in a ::Process::Status object. To maximize compatibility, however, these objects retain a bit-oriented interface. In the descriptions that follow, when we talk about the integer value of stat, we’re referring to this 16 bit value.

[ GitHub ]

  
# File 'process.c', line 522

VALUE
rb_last_status_get(void)
{
    return GET_THREAD()->last_status;
}