Ruby 2.4.0 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > Classクラス

class Class

クラス・モジュールの継承リスト: Class < Module < Object < Kernel < BasicObject

要約

クラスのクラスです。

より正確に言えば、個々のクラスはそれぞれメタクラスと呼ばれる名前のないクラスをクラスとして持っていて、Class はそのメタクラスのクラスです。この関係は少し複雑ですが、Ruby を利用するにあたっては特に重要ではありません。

クラスとモジュールには

という違いがありますが、それ以外のほとんどの機能は Module から継承されています。Module のメソッドのうち

は Class では未定義にされています。

特異メソッド

定義 説明
new(superclass = Object) -> Class
new(superclass = Object) {|klass| ... } -> Class

新しく名前の付いていない superclass のサブクラスを生成します。

インスタンスメソッド

定義 説明
_load(str) -> Class

Object#_dump を参照して下さい。

allocate -> object

自身のインスタンスを生成して返します。生成したオブジェクトは自身のインスタンスであること以外には何も特性を持ちません。

new(*args, &block) -> object

自身のインスタンスを生成して返します。このメソッドの引数はブロック引数も含め Object#initialize に渡されます。

superclass -> Class | nil

自身のスーパークラスを返します。

privateメソッド

定義 説明
inherited(subclass) -> ()

クラスのサブクラスが定義された時、新しく生成されたサブクラスを引数にインタプリタから呼び出されます。このメソッドが呼ばれるタイミングはクラス定義文の実行直前です。

継承したメソッド

! != __id__ __send__ instance_eval instance_exec method_missing singleton_method_added singleton_method_removed singleton_method_undefined < <= <=> === > >= alias_method ancestors append_features attr attr_accessor attr_reader attr_writer autoload autoload? class_eval class_exec class_variable_defined? class_variable_get class_variable_set class_variables const_defined? const_get const_missing const_set constants define_method deprecate_constant extend_object extended freeze include include? included included_modules inspect instance_method instance_methods method_added method_defined? method_removed method_undefined module_function prepend prepend_features prepended private private_class_method private_constant private_instance_methods private_method_defined? protected protected_instance_methods protected_method_defined? psych_yaml_as public public_class_method public_constant public_instance_method public_instance_methods public_method_defined? rake_extension refine remove_class_variable remove_const remove_method singleton_class? undef_method using .constants .nesting .used_modules !~ == =~ _dump class clone define_singleton_method display enum_for eql? equal? extend frozen? hash initialize initialize_copy instance_of? instance_variable_defined? instance_variable_get instance_variable_set instance_variables is_a? itself marshal_dump marshal_load method methods nil? object_id pretty_inspect pretty_print pretty_print_cycle pretty_print_inspect pretty_print_instance_variables private_methods protected_methods psych_to_yaml public_method public_methods public_send remove_instance_variable respond_to? respond_to_missing? send singleton_class singleton_method singleton_methods taint tainted? tap to_a to_ary to_hash to_int to_io to_proc to_regexp to_str trust untaint untrust untrusted? .yaml_tag ::ARGF ::ARGV ::DATA ::ENV ::FALSE ::NIL ::RUBY_COPYRIGHT ::RUBY_DESCRIPTION ::RUBY_ENGINE ::RUBY_ENGINE_VERSION ::RUBY_PATCHLEVEL ::RUBY_PLATFORM ::RUBY_RELEASE_DATE ::RUBY_REVISION ::RUBY_VERSION ::SCRIPT_LINES__ ::STDERR ::STDIN ::STDOUT ::TOPLEVEL_BINDING ::TRUE

追加されるメソッド

定義 説明 ライブラリ
json_creatable? -> bool

シリアライズされた JSON 形式の文字列から、インスタンスを作成するのにこのクラスを使用できる場合は真を返します。そうでない場合は、偽を返します。

json