Ruby 1.8.6
…defines the following constants:
ARGF ArgumentError ARGV Array Bignum Binding Class Comparable Continuation Data Dir Enumerable ENV EOFError Errno Exception FALSE FalseClass File FileTest Fixnum Float FloatDomainError GC Hash IndexError Integer Interrupt IO IOError Kernel LoadError LocalJumpError Marshal MatchData MatchingData Math Method Module NameError NIL NilClass NoMemoryError NoMethodError NotImplementedError Numeric Object ObjectSpace PLATFORM Precision Proc Process Range RangeError Regexp RegexpError RELEASE_DATE RUBY_PATCHLEVEL RUBY_PLATFORM RUBY_RELEASE_DATE RUBY_VERSION RuntimeError ScriptError SecurityError Signal SignalException StandardError STDERR STDIN STDOUT String Struct Symbol SyntaxError SystemCallError SystemExit SystemStackError Thread ThreadError ThreadGroup Time TOPLEVEL_BINDING TRUE TrueClass TypeError UnboundMethod VERSION ZeroDivisionError
As you can see, __FILE__
and __LINE__
are not included, because they are interpreter tokens (keywords, really).
NIL, TRUE and FALSE are just pointers to the values nil, true and false. ARGV are the parameters that were given to the process, and ARGF is the given file.
ENV is the accessor to the environment’s variables. TOPLEVEL_BINDING is pointing, well, to the top-level binding. The constants STDIN, STDOUT and STDERR are the three UNIX streams.
Everything else written in capital letters (except GC and IO) is information about the interpreter and Ruby version. Everything not written in CamelCase is a built-in Ruby class or module.
The constant DATA is only available when the __END__ marker is found somewhere in the source file. Data, on the other hand, is a class used internally for C pointers.
Ruby 1.8.7
…adds RUBY_COPYRIGHT and RUBY_DESCRIPTION to the list, and also the exception class StopIteration.
JRuby
…is based on Ruby 1.8.7, and adds the constants ENV_JAVA, JRUBY_VERSION, and RUBY_ENGINE to the list. It also defines the exceptions ConcurrencyError, Fatal and NativeException and the module Java.
Ruby 1.9.2
…has removed the deprecated PLATFORM, RELEASE_DATE and VERSION constants (in favor of the RUBY_
-prefixed variants). It also added the RUBY_ENGINE constant and a new RUBY_REVISION value. The Continuation class is gone, as is the Precision module. The deprecated alias MatchingData is also gone (use MatchData).
Ruby 1.9 defines some new classes: BasicObject, Encoding, Fiber, Random, and RubyVM. Also new are the exception classes EncodingError, FiberError, and KeyError.
Last but not least, Enumerator, Gem, Complex, Rational and Mutex are now loaded by default.