708件ヒット
[401-500件を表示]
(0.077秒)
キーワード
- < (12)
- <=> (12)
- ancestors (12)
-
append
_ features (12) - attr (12)
-
attr
_ accessor (4) -
attr
_ reader (4) -
attr
_ writer (4) - autoload (12)
-
class
_ eval (24) -
class
_ exec (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)
- inspect (12)
-
instance
_ method (12) -
instance
_ methods (12) -
method
_ added (12) -
method
_ defined? (12) -
method
_ removed (12) -
method
_ undefined (12) -
module
_ eval (24) -
module
_ exec (12) - name (12)
- prepend (12)
-
prepend
_ features (12) - prepended (12)
- private (48)
-
private
_ class _ method (24) -
private
_ constant (12) -
private
_ method _ defined? (12) -
protected
_ method _ defined? (12) -
public
_ class _ method (24) -
public
_ constant (12) -
public
_ method _ defined? (12) -
rake
_ extension (12) - refine (12)
-
remove
_ class _ variable (12) -
remove
_ const (12) -
remove
_ method (12) -
singleton
_ class? (12) -
to
_ s (12) -
undef
_ method (12)
検索結果
先頭5件
-
Module
# public _ method _ defined?(name , inherit=true) -> bool (21038.0) -
インスタンスメソッド name がモジュールに定義されており、 しかもその可視性が public であるときに true を返します。 そうでなければ false を返します。
...れたメソッドも対象になります。
@see Module#method_defined?, Module#private_method_defined?, Module#protected_method_defined?
//emlist[例][ruby]{
module A
def method1() end
end
class B
protected
def method2() end
end
class C < B
include A
def method3() end
end
A.method... -
Module
# undef _ method(*name) -> self (21038.0) -
このモジュールのインスタンスメソッド name を未定義にします。
...い。
//emlist[例][ruby]{
class A
def ok
puts 'A'
end
end
class B < A
def ok
puts 'B'
end
end
B.new.ok # => B
# undef_method の場合はスーパークラスに同名のメソッドがあっても
# その呼び出しはエラーになる
class B
undef_method :ok
end
B.new.......ッドがあると
# それが呼ばれる
class B
remove_method :ok
end
B.new.ok # => A
//}
また、undef 文と undef_method の違いは、
メソッド名を String または Symbol で与えられることです。
//emlist[例][ruby]{
module M1
def foo
end
def self.moo
undef f......oo
end
end
M1.instance_methods false #=> ["foo"]
M1.moo
M1.instance_methods false #=> []
module M2
def foo
end
def self.moo
undef_method :foo
end
end
M2.instance_methods false #=> ["foo"]
M2.moo
M2.instance_methods false #=> []
//}... -
Module
# const _ get(name , inherit = true) -> object (21032.0) -
name で指定される名前の定数の値を取り出します。
...name で指定される名前の定数の値を取り出します。
Module#const_defined? と違って Object を特別扱いすることはありません。
@param name 定数名。String か Symbol で指定します。
完全修飾名を指定しなかった場合はモジュー......いないときに発生します。
//emlist[例][ruby]{
module Bar
BAR = 1
end
class Object
include Bar
end
# Object では include されたモジュールに定義された定数を見付ける
p Object.const_get(:BAR) # => 1
class Baz
include Bar
end
# Object以外でも同様
p Baz.c......ror
# 第二引数に false を指定すると自分自身に定義された定数から探す
p Baz.const_get(:BAR, false) #=> raise NameError
# 完全修飾名を指定すると include や自分自身へ定義されていない場合でも参照できる
p Class.const_get("Bar::BAR") # => 1
//}... -
Module
# <=>(other) -> Integer | nil (21026.0) -
self と other の継承関係を比較します。
...なければ
nil を返します。
@param other 比較対象のクラスやモジュール
//emlist[例][ruby]{
module Foo
end
class Bar
include Foo
end
class Baz < Bar
end
class Qux
end
p Bar <=> Foo # => -1
p Baz <=> Bar # => -1
p Baz <=> Foo # => -1
p Baz <=> Qux # => nil
p Q... -
Module
# const _ defined?(name , inherit = true) -> bool (21026.0) -
モジュールに name で指定される名前の定数が定義されている時真 を返します。
...は対象にはなりません。
//emlist[例][ruby]{
module Kernel
FOO = 1
end
# Object は include したモジュールの定数に対しても
# 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?(... -
Module
# const _ source _ location(name , inherited = true) -> [String , Integer] (21026.0) -
name で指定した定数の定義を含むソースコードのファイル名と行番号を配列で返します。
...った場合は空の配列を返します。
//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
include M
C4 = 4
end
class A # 継続して A を定義する
C2 = 8 # 定数を再定義する
end......] -- Object を継承している為
p M.const_source_location('A') # => ["test.rb", 1] -- Object は継承していないが追加で modules をチェックする
p Object.const_source_location('A::C1') # => ["test.rb", 2] -- ネストの指定もサポートしている
p Object.... -
Module
# include?(mod) -> bool (21026.0) -
self かその親クラス / 親モジュールがモジュール mod を インクルードしていれば true を返します。
...クラス / 親モジュールがモジュール mod を
インクルードしていれば true を返します。
@param mod Module を指定します。
//emlist[例][ruby]{
module M
end
class C1
include M
end
class C2 < C1
end
p C1.include?(M) # => true
p C2.include?(M) # => true
//}... -
Module
# private _ constant(*name) -> self (21026.0) -
name で指定した定数の可視性を private に変更します。
...数を指定した場合に発生します。
@return self を返します。
@see Module#public_constant, Object#untrusted?
//emlist[例][ruby]{
module Foo
BAR = 'bar'
class Baz; end
QUX = 'qux'
class Quux; end
private_constant :QUX
private_constant :Quux
end
Foo::BAR # => "bar"
F......しない定数を指定した場合に発生します。
@return self を返します。
@see Module#public_constant
//emlist[例][ruby]{
module Foo
BAR = 'bar'
class Baz; end
QUX = 'qux'
class Quux; end
private_constant :QUX
private_constant :Quux
end
Foo::BAR # => "bar"
Foo::Baz... -
Module
# public _ constant(*name) -> self (21026.0) -
name で指定した定数の可視性を public に変更します。
...{
module SampleModule
class SampleInnerClass
end
# => 非公開クラスであることを明示するために private にする
private_constant :SampleInnerClass
end
begin
SampleModule::SampleInnerClass
rescue => e
e # => #<NameError: private constant SampleModule::SampleInnerClass......referenced>
end
module SampleModule
# => 非公開クラスであることは承知で利用するために public にする
public_constant :SampleInnerClass
end
SampleModule::SampleInnerClass # => SampleModule::SampleInnerClass
//}
@see Module#private_constant, Object#untrusted?...