516件ヒット
[501-516件を表示]
(0.136秒)
キーワード
-
alias
_ method (12) - attr (36)
-
attr
_ accessor (12) -
attr
_ reader (12) -
attr
_ writer (12) - autoload (12)
- autoload? (12)
-
class
_ variable _ defined? (12) -
class
_ variable _ get (12) -
class
_ variable _ set (12) -
const
_ defined? (12) -
const
_ get (12) -
const
_ source _ location (12) -
deprecate
_ constant (12) - inspect (12)
-
method
_ defined? (12) -
module
_ function (24) - name (12)
- private (48)
-
private
_ class _ method (24) -
private
_ constant (12) -
private
_ method _ defined? (12) - protected (48)
-
protected
_ method _ defined? (12) - public (36)
-
public
_ method _ defined? (12) -
rake
_ extension (12) -
remove
_ class _ variable (12) -
remove
_ const (12) -
remove
_ method (12) -
to
_ s (12)
検索結果
-
Module
# const _ defined?(name , inherit = true) -> bool (120.0) -
モジュールに name で指定される名前の定数が定義されている時真 を返します。
...ことができます。
@param name String, Symbol で指定される定数名。
@param inherit false を指定するとスーパークラスや include したモジュールで
定義された定数は対象にはなりません。
//emlist[例][ruby]{
module Kernel
FOO = 1
end
# Obj......ルの定数に対しても
# true を返す
p Object.const_defined?(:FOO) # => true
module Bar
BAR = 1
end
class Object
include Bar
end
# ユーザ定義のモジュールに対しても同様
p Object.const_defined?(:BAR) # => true
class Baz
include Bar
end
# Object 以外でも同様......になった
# 第二引数のデフォルト値が true であるため
p Baz.const_defined?(:BAR) # => true
# 第二引数を false にした場合
p Baz.const_defined?(:BAR, false) # => false
//}... -
Module
# module _ function(*name) -> Array (115.0) -
メソッドをモジュール関数にします。
...与えられた時には配列にまとめて返します。
引数なしの時は nil を返します。
@param name String または Symbol を 0 個以上指定します。
=== 注意
module_function はメソッドに「モジュール関数」という属性をつけるメ
ソッドではな......st[例][ruby]{
module M
def foo
p "foo"
end
module_function :foo
alias bar foo
end
M.foo # => "foo"
M.bar # => undefined method `bar' for Foo:Module (NoMethodError)
//}
このコードでは、モジュール関数 foo と
プライベートインスタンスメソッド bar を定......付けるには、
以下のように、先に別名を定義してから
それぞれをモジュール関数にしなければいけません。
//emlist[例][ruby]{
module M
def foo
p "foo"
end
alias bar foo
module_function :foo, :bar
end
M.foo # => "foo"
M.bar # => "foo"
//}...