るりまサーチ

最速Rubyリファレンスマニュアル検索!
975件ヒット [401-500件を表示] (0.055秒)

別のキーワード

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

検索結果

<< < ... 3 4 5 6 7 ... > >>

Module#const_defined?(name, inherit = true) -> bool (38.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?(:BAR, fal...

Module#const_source_location(name, inherited = true) -> [String, Integer] (38.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


p B.const_source_location('C4'...
...] -- 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#method_undefined(name) -> () (38.0)

このモジュールのインスタンスメソッド name が Module#undef_method によって削除されるか、 undef 文により未定義にされると、インタプリタがこのメソッドを呼び出します。

...このモジュールのインスタンスメソッド name が
Module
#undef_method によって削除されるか、
undef 文により未定義にされると、インタプリタがこのメソッドを呼び出します。

特異メソッドの削除をフックするには
BasicObject#singlet...
...たメソッド名が Symbol で渡されます。

//emlist[例][ruby]{
class C
def C.method_undefined(name)
puts "method C\##{name} was undefined"
end


def foo
end

def bar
end


undef_method :foo
undef bar
end

//}

実行結果:

method C#foo was undefined
method C#bar was u...

Module#public_constant(*name) -> self (38.0)

name で指定した定数の可視性を public に変更します。

...t[例][ruby]{
module
SampleModule
class SampleInnerClass
end


# => 非公開クラスであることを明示するために private にする
private_constant :SampleInnerClass
end


begin
SampleModule::SampleInnerClass
rescue => e
e # => #<NameError: private constant SampleModule::Sampl...
...eInnerClass referenced>
end


module
SampleModule
# => 非公開クラスであることは承知で利用するために public にする
public_constant :SampleInnerClass
end


SampleModule::SampleInnerClass # => SampleModule::SampleInnerClass
//}

@see Module#private_constant, Object#untrusted?...
...eInnerClass referenced>
end


module
SampleModule
# => 非公開クラスであることは承知で利用するために public にする
public_constant :SampleInnerClass
end


SampleModule::SampleInnerClass # => SampleModule::SampleInnerClass
//}

@see Module#private_constant...

Module#remove_method(*name) -> self (38.0)

インスタンスメソッド name をモジュールから削除します。

...します。

Ruby
1.8.0 以降は複数のメソッド名を指定して一度に削除できます。

@param name 0 個以上の String か Symbol を指定します。

@raise NameError 指定したメソッドが定義されていない場合に発生します。

//emlist[例][ruby]{
class C...
...def foo
end

remove_method :foo
remove_method :no_such_method # 例外 NameError が発生
end

//}

@see Module#undef_method...

絞り込み条件を変える

Module#<=(other) -> bool | nil (32.0)

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

...@raise TypeError other がクラスやモジュールではない場合に発生します。

@see Module#<

//emlist[例][ruby]{
module
Foo; end
module
Bar
include Foo
end

module
Baz
prepend Foo
end


Bar.ancestors # => [Bar, Foo]
Foo <= Bar # => false
Bar <= Foo # => true

Baz.ancestors # => [F...

Module#>(other) -> bool | nil (32.0)

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

...ee Module#<

//emlist[例][ruby]{
module
Awesome; end
module
Included
include Awesome
end

module
Prepended
prepend Awesome
end


Included.ancestors # => [Included, Awesome]
Awesome > Included # => true
Included > Awesome # => false

Prepended.ancestors # => [Awesome, Prepended]
Awesome > Prepende...
...d # => true
Prepended > Awesome # => false

Awesome > Awesome # => false
Awesome > Object # => nil
//}...

Module#>=(other) -> bool | nil (32.0)

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

...@raise TypeError other がクラスやモジュールではない場合に発生します。

@see Module#<

//emlist[例][ruby]{
module
Foo; end
module
Bar
include Foo
end

module
Baz
prepend Foo
end


Bar.ancestors # => [Bar, Foo]
Foo >= Bar # => true
Bar >= Foo # => false

Baz.ancestors # => [F...

Module#ancestors -> [Class, Module] (32.0)

クラス、モジュールのスーパークラスとインクルードしているモジュール を優先順位順に配列に格納して返します。

...先順位順に配列に格納して返します。

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

class Bar
include Foo
end

class Baz < Bar
p ancestors
p included_modules
p superclass
end

# => [Baz, Bar, Foo, Object, Kernel, BasicObject]
# => [Foo, Kernel]
# => Bar
//}

@see Module#included_modules...
<< < ... 3 4 5 6 7 ... > >>