Global Constants

Table 5 describes all of Ruby’s global constants.

Table 5. Global constants

Constant

Description

ARGF

I/O-like stream that allows access to a virtual concatenation of all files provided on the command line, or standard input if no files are provided. Synonym for $<.

ARGV

Array that contains all the command-line arguments passed to a program. Synonym for $*.

DATA

An input stream for reading the lines of code following the _ _END_ _ directive. Not defined if _ _END_ _ is not present in code.

ENV

A hash-like object containing the program’s environment variables; can be treated as a hash.

FALSE

Synonym for false; false is preferred.

NIL

Synonym for nil; nil is preferred.

PLATFORM

Synonym for RUBY_PLATFORM. Deprecated.

RELEASE_DATE

Synonym for RUBY_RELEASE_DATE. Deprecated.

RUBY_PLATFORM

A string indicating the platform of the Ruby interpreter; e.g., “powerpc-darwin8.9.0.”

RUBY_RELEASE_DATE

A string indicating the release date of the Ruby interpreter; e.g., “2007-03-13.”

RUBY_VERSION

The Ruby version; e.g., “1.8.6.”

STDERR

Standard error output stream with default value of $stderr.

STDIN

Standard input stream with default value of $stdin.

STDOUT

Standard output stream with default value of $stdout.

TOPLEVEL_BINDING

A Binding object at Ruby’s top level.

TRUE

Synonym for true; true is preferred.

VERSION

Synonym for RUBY_VERSION. Deprecated.

Get Ruby Pocket Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.