るりまサーチ

最速Rubyリファレンスマニュアル検索!
264件ヒット [101-200件を表示] (0.097秒)

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

検索結果

<< < 1 2 3 > >>

Module#const_defined?(name, inherit = true) -> bool (62.0)

モジュールに name で指定される名前の定数が定義されている時真 を返します。

...クラスや include したモジュールで定義された定数を検索対象
にするかどうかは第二引数で制御することができます。

@param name String, Symbol で指定される定数名。

@param inherit false を指定するとスーパークラスや include したモ...
...にはなりません。

//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?(:BAR, fal...

Module#const_get(name, inherit = true) -> object (56.0)

name で指定される名前の定数の値を取り出します。

...name で指定される名前の定数の値を取り出します。

Module
#const_defined? と違って Object を特別扱いすることはありません。

@param name 定数名。String か Symbol で指定します。
完全修飾名を指定しなかった場合はモジュー...
...クラスや include したモジュールで
定義された定数は対象にはなりません。

@raise NameError 定数が定義されていないときに発生します。

//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.const_get(:BAR) # => 1
# 定義されていない定数
p Baz.const_get(:NOT_DEFINED) #=> raise NameError
# 第二引数に false を指定す...

Module#private_method_defined?(name, inherit=true) -> bool (56.0)

インスタンスメソッド name がモジュールに定義されており、 しかもその可視性が private であるときに true を返します。 そうでなければ false を返します。

...スや include したモジュールで
定義されたメソッドも対象になります。

@see Module#method_defined?, Module#public_method_defined?, Module#protected_method_defined?

//emlist[例][ruby]{
module
A
def method1() end
end

class B
private
def method2() end
end

class...
...C < B
include
A
def method3() end
end


A.method_defined? :method1 #=> true
C.private_method_defined? "method1" #=> false
C.private_method_defined? "method2" #=> true
C.private_method_defined? "method2", true #=> true
C.private_method_defined? "method2", f...

Module#protected_method_defined?(name, inherit=true) -> bool (56.0)

インスタンスメソッド name がモジュールに定義されており、 しかもその可視性が protected であるときに true を返します。 そうでなければ false を返します。

...スや include したモジュールで
定義されたメソッドも対象になります。

@see Module#method_defined?, Module#public_method_defined?, Module#private_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_defined? :method1 #=> true
C.protected_method_defined? "method1" #=> false
C.protected_method_defined? "method2" #=> true
C.protected_method_defined? "method2", true #=> true
C.protected_method_defined? "metho...

Module#public_method_defined?(name, inherit=true) -> bool (56.0)

インスタンスメソッド name がモジュールに定義されており、 しかもその可視性が public であるときに true を返します。 そうでなければ false を返します。

... include したモジュールで
定義されたメソッドも対象になります。

@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_defined? :method1 #=> true
C.public_method_defined? "method1" #=> true
C.public_method_defined? "method1", true #=> true
C.public_method_defined? "method1", false #=> true
C.public_method_defined? "method2" #=>...

絞り込み条件を変える

Module#const_source_location(name, inherited = true) -> [String, Integer] (50.0)

name で指定した定数の定義を含むソースコードのファイル名と行番号を配列で返します。

...します。

@param name Symbol,String で定数の名前を指定します。
@param inherited true を指定するとスーパークラスや include したモジュールで定義された定数が対象にはなります。false を指定した場合 対象にはなりません。
@return ソ...
...返します。

//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


p B.const_source_location('C4'...
...# => ["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('C2') # => ["test.rb", 16] -- 最後に定義された位置を返...

Module#private_instance_methods(inherited_too = true) -> [Symbol] (50.0)

そのモジュールで定義されている private メソッド名 の一覧を配列で返します。

...るメソッドのみ返します。

@see Object#private_methods, Module#instance_methods

//emlist[例][ruby]{
module
Foo
def foo; end
private def bar; end
end


module
Bar
include
Foo

def baz; end
private def qux; end
end


Bar.private_instance_methods # => [:qux, :bar]
Bar.private_insta...

Module#<(other) -> bool | nil (38.0)

比較演算子。self が other の子孫である場合、 true を返します。 self が other の先祖か同一のクラス/モジュールである場合、false を返します。

.../emlist[例][ruby]{
module
Foo
end

class Bar
include
Foo
end

class Baz < Bar
end

class Qux
end

p Bar < Foo # => true
p Baz < Bar # => true
p Baz < Foo # => true
p Baz < Qux # => nil
p Baz > Qux # => nil

p Foo < Object.new # => in `<': compared with non class/module (TypeError)...

Module#<=>(other) -> Integer | nil (38.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...
<< < 1 2 3 > >>