Ruby 1.9.2 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > 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) -> ()

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

継承したメソッド

! != < <= <=> === > >= 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 extend_object extended include include? included included_modules infect_with_assertions instance_method instance_methods method_added method_defined? method_removed method_undefined module_function name private private_class_method private_instance_methods private_method_defined? protected protected_instance_methods protected_method_defined? public public_class_method public_instance_methods public_method_defined? rake_extension remove_class_variable remove_const remove_method undef_method .constants .nesting == =~ __id__ __send__ _dump class clone dclone display enum_for eql? equal? extend freeze frozen? hash initialize initialize_copy inspect instance_eval instance_exec instance_of? instance_variable_defined? instance_variable_get instance_variable_set instance_variables is_a? marshal_dump marshal_load method method_missing methods must_be must_be_close_to must_be_empty must_be_instance_of must_be_kind_of must_be_nil must_be_same_as must_be_within_epsilon must_equal must_include must_match must_raise must_respond_to must_send must_throw nil? pretty_inspect pretty_print pretty_print_cycle pretty_print_inspect pretty_print_instance_variables private_methods protected_methods public_methods remove_instance_variable respond_to? respond_to_missing? singleton_class singleton_method_added singleton_method_removed singleton_method_undefined singleton_methods taint tainted? tap to_a to_ary to_hash to_int to_io to_proc to_regexp to_str to_yaml_properties to_yaml_style trust untaint untrust untrusted? wont_be wont_be_close_to wont_be_empty wont_be_instance_of wont_be_kind_of wont_be_nil wont_be_same_as wont_be_within_epsilon wont_equal wont_include wont_match wont_respond_to

追加されるメソッド

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

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

json
to_yaml(opts = {})

例外を発生する。

yaml