それマグで!

知識はカップより、マグでゆっくり頂きます。 takuya_1stのブログ

習慣に早くから配慮した者は、 おそらく人生の実りも大きい。

Rubyの定義済の定数一覧

Ruby で定義済の定数を確認する。

クラス定義の外(トッ プレベル)で定義された定数は Object に所属することになります。

Object.constants

ということになる。

たとえば、RUBY_XXXXを見つけるには

>> Object.constants.grep(/ruby/i)
[
    [ 0] :RubyVM,
    [ 1] :RUBY_VERSION,
    [ 2] :RUBY_RELEASE_DATE,
    [ 3] :RUBY_PLATFORM,
    [ 4] :RUBY_PATCHLEVEL,
    [ 5] :RUBY_REVISION,
    [ 6] :RUBY_DESCRIPTION,
    [ 7] :RUBY_COPYRIGHT,
    [ 8] :RUBY_ENGINE,
    [ 9] :RubyToken,
    [10] :RubyLex,
    [11] :RUBYGEMS_ACTIVATION_MONITOR
]
>>

などとなる。

ちょっと困ったことに、requireしたモジュールも定数なので・・・たくさんありますね。

>> Object.constants
[
    [  0] :Object,
    [  1] :Module,
    [  2] :Class,
    [  3] :BasicObject,
    [  4] :Kernel,
    [  5] :NilClass,
    [  6] :NIL,
    [  7] :Data,
    [  8] :TrueClass,
    [  9] :TRUE,
    [ 10] :FalseClass,
    [ 11] :FALSE,
    [ 12] :Encoding,
    [ 13] :Comparable,
    [ 14] :Enumerable,
    [ 15] :String,
    [ 16] :Symbol,
    [ 17] :Exception,
    [ 18] :SystemExit,
    [ 19] :SignalException,
    [ 20] :Interrupt,
    [ 21] :StandardError,
    [ 22] :TypeError,
    [ 23] :ArgumentError,
    [ 24] :IndexError,
    [ 25] :KeyError,
    [ 26] :RangeError,
    [ 27] :ScriptError,
    [ 28] :SyntaxError,
    [ 29] :LoadError,
    [ 30] :NotImplementedError,
    [ 31] :NameError,
    [ 32] :NoMethodError,
    [ 33] :RuntimeError,
    [ 34] :SecurityError,
    [ 35] :NoMemoryError,
    [ 36] :EncodingError,
    [ 37] :SystemCallError,
    [ 38] :Errno,
    [ 39] :ZeroDivisionError,
    [ 40] :FloatDomainError,
    [ 41] :Numeric,
    [ 42] :Integer,
    [ 43] :Fixnum,
    [ 44] :Float,
    [ 45] :Bignum,
    [ 46] :Array,
    [ 47] :Hash,
    [ 48] :ENV,
    [ 49] :Struct,
    [ 50] :RegexpError,
    [ 51] :Regexp,
    [ 52] :MatchData,
    [ 53] :Marshal,
    [ 54] :Range,
    [ 55] :IOError,
    [ 56] :EOFError,
    [ 57] :IO,
    [ 58] :STDIN,
    [ 59] :STDOUT,
    [ 60] :STDERR,
    [ 61] :ARGF,
    [ 62] :FileTest,
    [ 63] :File,
    [ 64] :Dir,
    [ 65] :Time,
    [ 66] :Random,
    [ 67] :Signal,
    [ 68] :Process,
    [ 69] :Proc,
    [ 70] :LocalJumpError,
    [ 71] :SystemStackError,
    [ 72] :Method,
    [ 73] :UnboundMethod,
    [ 74] :Binding,
    [ 75] :Math,
    [ 76] :GC,
    [ 77] :ObjectSpace,
    [ 78] :Enumerator,
    [ 79] :StopIteration,
    [ 80] :RubyVM,
    [ 81] :Thread,
    [ 82] :TOPLEVEL_BINDING,
    [ 83] :ThreadGroup,
    [ 84] :Mutex,
    [ 85] :ThreadError,
    [ 86] :Fiber,
    [ 87] :FiberError,
    [ 88] :Rational,
    [ 89] :Complex,
    [ 90] :RUBY_VERSION,
    [ 91] :RUBY_RELEASE_DATE,
    [ 92] :RUBY_PLATFORM,
    [ 93] :RUBY_PATCHLEVEL,
    [ 94] :RUBY_REVISION,
    [ 95] :RUBY_DESCRIPTION,
    [ 96] :RUBY_COPYRIGHT,
    [ 97] :RUBY_ENGINE,
    [ 98] :TracePoint,
    [ 99] :ARGV,
    [100] :Gem,
    [101] :RbConfig,
    [102] :Config,
    [103] :CROSS_COMPILING,
    [104] :ConditionVariable,
    [105] :Queue,
    [106] :SizedQueue,
    [107] :MonitorMixin,
    [108] :Monitor,
    [109] :PrettyPrint,
    [110] :PP,
    [111] :Pry,
    [112] :Forwardable,
    [113] :SingleForwardable,
    [114] :MethodSource,
    [115] :Shellwords,
    [116] :StringIO,
    [117] :CodeRay,
    [118] :Slop,
    [119] :Delegator,
    [120] :SimpleDelegator,
    [121] :FileUtils,
    [122] :Etc,
    [123] :Tempfile,
    [124] :Pathname,
    [125] :PryDebugger,
    [126] :Debugger,
    [127] :BasicSocket,
    [128] :Socket,
    [129] :SocketError,
    [130] :IPSocket,
    [131] :TCPSocket,
    [132] :TCPServer,
    [133] :UDPSocket,
    [134] :UNIXSocket,
    [135] :UNIXServer,
    [136] :Addrinfo,
    [137] :SCRIPT_LINES__,
    [138] :Digest,
    [139] :Set,
    [140] :SortedSet,
    [141] :TraceLineNumbers,
    [142] :LineCache,
    [143] :Readline,
    [144] :Columnize,
    [145] :Exception2MessageMapper,
    [146] :IRB,
    [147] :RubyToken,
    [148] :RubyLex,
    [149] :Psych,
    [150] :StringScanner,
    [151] :ScanError,
    [152] :Date,
    [153] :DateTime,
    [154] :YAML,
    [155] :Printers,
    [156] :MIME,
    [157] :JSON,
    [158] :OpenStruct,
    [159] :Mutex_m,
    [160] :CGI,
    [161] :Timeout,
    [162] :TimeoutError,
    [163] :Net,
    [164] :URI,
    [165] :Zlib,
    [166] :OpenSSL,
    [167] :Fcntl,
    [168] :SecureRandom,
    [169] :Nokogiri,
    [170] :Racc,
    [171] :ParseError,
    [172] :WEBrick,
    [173] :Mechanize,
    [174] :HTTP,
    [175] :DomainName,
    [176] :UNF,
    [177] :IPAddr,
    [178] :Base64,
    [179] :NKF,
    [180] :Kconv,
    [181] :Webrobots,
    [182] :WebRobots,
    [183] :DRb,
    [184] :DRbObject,
    [185] :DRbUndumped,
    [186] :DRbIdConv,
    [187] :AwesomePrint,
    [188] :RUBYGEMS_ACTIVATION_MONITOR
]

参考資料

変数と定数 (Ruby 2.0.0)