821件ヒット
[101-200件を表示]
(0.140秒)
ライブラリ
- ビルトイン (808)
-
minitest
/ spec (1) - rake (12)
キーワード
- < (12)
- <= (12)
- <=> (12)
- > (12)
- >= (12)
-
alias
_ method (12) - attr (24)
-
attr
_ accessor (8) -
attr
_ reader (8) -
attr
_ writer (12) - autoload (12)
- autoload? (12)
-
class
_ eval (12) -
class
_ variable _ defined? (12) -
class
_ variable _ get (12) -
class
_ variable _ set (12) -
class
_ variables (12) -
const
_ defined? (12) -
const
_ get (12) -
const
_ missing (12) -
const
_ source _ location (12) - constants (12)
-
define
_ method (24) - include (12)
- include? (12)
- included (12)
-
included
_ modules (12) -
infect
_ with _ assertions (1) - inspect (12)
-
instance
_ method (12) -
instance
_ methods (12) -
method
_ defined? (12) -
method
_ undefined (12) -
module
_ eval (12) -
module
_ function (36) - name (12)
- private (48)
-
private
_ class _ method (24) -
private
_ constant (12) -
private
_ instance _ methods (12) -
private
_ method _ defined? (12) - protected (24)
-
protected
_ instance _ methods (12) -
protected
_ method _ defined? (12) - public (48)
-
public
_ class _ method (24) -
public
_ constant (12) -
public
_ instance _ method (12) -
public
_ instance _ methods (12) -
public
_ method _ defined? (12) -
rake
_ extension (12) - refine (12)
-
remove
_ class _ variable (12) -
ruby2
_ keywords (12) -
singleton
_ class? (12) -
to
_ s (12) - using (12)
検索結果
先頭5件
-
Module
# class _ variable _ defined?(name) -> bool (6102.0) -
name で与えられた名前のクラス変数がモジュールに存在する場合 true を 返します。
...@param name Symbol か String を指定します。
//emlist[例][ruby]{
class Fred
@@foo = 99
end
Fred.class_variable_defined?(:@@foo) #=> true
Fred.class_variable_defined?(:@@bar) #=> false
Fred.class_variable_defined?('@@foo') #=> true
Fred.class_variable_defined?('@@bar') #=> fals... -
Module
# class _ variable _ get(name) -> object (6102.0) -
クラス/モジュールに定義されているクラス変数 name の値を返します。
...me の値を返します。
@param name String または Symbol を指定します。
@raise NameError クラス変数 name が定義されていない場合、発生します。
//emlist[例][ruby]{
class Fred
@@foo = 99
end
def Fred.foo
class_variable_get(:@@foo)
end
p Fred.foo #=> 99
//}... -
Module
# class _ variable _ set(name , val) -> object (6102.0) -
クラス/モジュールにクラス変数 name を定義して、その値として val をセットします。val を返します。
...して
val をセットします。val を返します。
@param name String または Symbol を指定します。
//emlist[例][ruby]{
class Fred
@@foo = 99
def foo
@@foo
end
end
def Fred.foo(val)
class_variable_set(:@@foo, val)
end
p Fred.foo(101) # => 101
p Fred.new.foo # =>... -
Module
# class _ variables(inherit = true) -> [Symbol] (6102.0) -
クラス/モジュールに定義されているクラス変数の名前の配列を返します。
...am inherit false を指定しない場合はスーパークラスやインクルードして
いるモジュールのクラス変数を含みます。
//emlist[例][ruby]{
class One
@@var1 = 1
end
class Two < One
@@var2 = 2
end
One.class_variables # => [:@@var1]
Two.class_variab......les # => [:@@var2, :@@var1]
Two.class_variables(false) # => [:@@var2]
//}
@see Module.constants, Kernel.#local_variables, Kernel.#global_variables, Object#instance_variables, Module#constants... -
Module
# const _ missing(name) (6102.0) -
定義されていない定数を参照したときに Ruby インタプリタが このメソッドを呼びます。
...の Symbol
@raise NameError このメソッドを呼び出した場合、デフォルトで発生する例外
//emlist[例][ruby]{
class Foo
def Foo.const_missing(id)
warn "undefined constant #{id.inspect}"
end
Bar
end
Foo::Bar
# => undefined constant :Bar
# undefined constant :Bar... -
Module
# const _ source _ location(name , inherited = true) -> [String , Integer] (6102.0) -
name で指定した定数の定義を含むソースコードのファイル名と行番号を配列で返します。
...スコードのファイル名と行番号を配列で返します。
@param name Symbol,String で定数の名前を指定します。
@param inherited true を指定するとスーパークラスや include したモジュールで定義された定数が対象にはなります。false を指......nil を返します。
定数は見つかったがソースファイルが見つからなかった場合は空の配列を返します。
//emlist[例][ruby]{
# test.rb:
class A # line 1
C1 = 1
C2 = 2
end
module M # line 6
C3 = 3
end
class B < A # line 10
inclu......ocation('C4') # => ["test.rb", 12]
p B.const_source_location('C3') # => ["test.rb", 7]
p B.const_source_location('C1') # => ["test.rb", 2]
p B.const_source_location('C3', false) # => nil -- include したモジュールは検索しない
p A.const_source_location(... -
Module
# define _ method(name) { . . . } -> Symbol (6102.0) -
インスタンスメソッド name を定義します。
...、定義したメソッドの実行時にブロックが
レシーバクラスのインスタンスの上で BasicObject#instance_eval されます。
@param name メソッド名を String または Symbol を指定します。
@param method Proc、Method あるいは UnboundMethod の
い......Symbol を返します。
@raise TypeError method に同じクラス、サブクラス、モジュール以外のメソッ
ドを指定した場合に発生します。
//emlist[例][ruby]{
class Foo
def foo() p :foo end
define_method(:bar, instance_method(:foo))
end
Foo.new.... -
Module
# define _ method(name , method) -> Symbol (6102.0) -
インスタンスメソッド name を定義します。
...、定義したメソッドの実行時にブロックが
レシーバクラスのインスタンスの上で BasicObject#instance_eval されます。
@param name メソッド名を String または Symbol を指定します。
@param method Proc、Method あるいは UnboundMethod の
い......Symbol を返します。
@raise TypeError method に同じクラス、サブクラス、モジュール以外のメソッ
ドを指定した場合に発生します。
//emlist[例][ruby]{
class Foo
def foo() p :foo end
define_method(:bar, instance_method(:foo))
end
Foo.new.... -
Module
# include(*mod) -> self (6102.0) -
モジュール mod をインクルードします。
...す。
@param mod Module のインスタンス( Enumerable など)を指定します。
@raise ArgumentError 継承関係が循環してしまうような include を行った場合に発生します。
//emlist[例][ruby]{
module M
end
module M2
include M
end
module M
include M2
end
//}
実......行結果:
-:3:in `append_features': cyclic include detected (ArgumentError)
from -:3:in `include'
from -:3
インクルードとは、指定されたモジュールの定義
(メソッド、定数) を引き継ぐことです。
インクルードは多重継承の代わり......に用いられており、 mix-in とも呼びます。
//emlist[例][ruby]{
class C
include FileTest
include Math
end
p C.ancestors
# => [C, Math, FileTest, Object, Kernel]
//}
モジュールの機能追加は、クラスの継承関係の間にそのモジュールが挿入
されるこ...