Rubyの組み込みクラスの一覧を表示してみる
組み込みクラスの一覧を表示してみたいと思い立った。
考えたのは
- Objectの定数一覧取得
- それぞれの定数からクラスを得る
- そのクラスがClassであれば、組み込みクラス
[8] pry(main)> puts Object.constants.select { |x| Kernel.const_get(x).class == Class } Object Module Class BasicObject NilClass Data TrueClass FalseClass Encoding String Symbol Exception SystemExit SignalException Interrupt StandardError TypeError ArgumentError IndexError KeyError RangeError ScriptError SyntaxError LoadError NotImplementedError NameError NoMethodError RuntimeError SecurityError NoMemoryError EncodingError SystemCallError UncaughtThrowError ZeroDivisionError FloatDomainError Numeric Integer Fixnum Float Bignum Array Hash Struct RegexpError Regexp MatchData Range IOError EOFError IO File Dir Time Random Proc LocalJumpError SystemStackError Method UnboundMethod Binding Enumerator StopIteration RubyVM Thread ThreadGroup ThreadError ClosedQueueError Mutex Queue SizedQueue ConditionVariable Fiber FiberError Rational Complex TracePoint StringIO Monitor Delegator SimpleDelegator PrettyPrint PP Pry Slop Tempfile Pathname Insertion SymbolHash OpenStruct OptionParser OptParse Logger StringScanner ScanError => nil
うまくいっている模様。*Errorは例外クラスと
Errorは例外クラス。
普段見慣れないものもかなりある。