るりまサーチ

最速Rubyリファレンスマニュアル検索!
131件ヒット [1-100件を表示] (0.122秒)

別のキーワード

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

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 > >>

Module#include(*mod) -> self (18252.0)

モジュール mod をインクルードします。

...定します。

@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 (Argument...
...in `include'
from -:3


インクルードとは、指定されたモジュールの定義
(メソッド、定数) を引き継ぐことです。
インクルードは多重継承の代わりに用いられており、 mix-in とも呼びます。

//emlist[例][ruby]{
class C
include
Fi...
...leTest
include
Math
end


p C.ancestors

# => [C, Math, FileTest, Object, Kernel]
//}

モジュールの機能追加は、クラスの継承関係の間にそのモジュールが挿入
されることで実現されています。従って、メソッドの探索などは
スーパークラスよ...

Object#respond_to?(name, include_all = false) -> bool (246.0)

オブジェクトがメソッド name を持つとき真を返します。

...します。

※ NotImplementedError が発生する場合に false を返すのは
Ruby
の組み込みライブラリや標準ライブラリなど、C言語で実装されているメソッドのみです。
Ruby
で実装されたメソッドで NotImplementedError が発生する場合は true...
...です。

@param include_all private メソッドと protected メソッドを確認の対象に
含めるかを true か false で指定します。省略した場合
は false(含めない) を指定した事になります。

//emlist[][ruby]{
class F
def...
...hello
"Bonjour"
end

end


class D
private
def hello
"Guten Tag"
end

end

list = [F.new,D.new]

list.each{|it| puts it.hello if it.respond_to?(:hello)}
#=> Bonjour

list.each{|it| it.instance_eval("puts hello if it.respond_to?(:hello, true)")}
#=> Bonjour
# Guten Tag

module Template...

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

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

...クラスや include したモジュールで
定義された定数は対象にはなりません。

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

//emlist[例][ruby]{
module Bar
BAR = 1
end

class Object
include
Bar
end

# Object では include された...
...Baz
include
Bar
end

# Object以外でも同様
p Baz.const_get(:BAR) # => 1
# 定義されていない定数
p Baz.const_get(:NOT_DEFINED) #=> raise NameError
# 第二引数に false を指定すると自分自身に定義された定数から探す
p Baz.const_get(:BAR, false) #=> raise Nam...
...eError
# 完全修飾名を指定すると include や自分自身へ定義されていない場合でも参照できる
p Class.const_get("Bar::BAR") # => 1
//}...

UnboundMethod#bind(obj) -> Method (61.0)

self を obj にバインドした Method オブジェクトを生成して返します。

...のインスタンスのみです。

@raise TypeError objがbindできないオブジェクトである場合に発生します

//emlist[例][ruby]{
# クラスのインスタンスメソッドの UnboundMethod の場合
class Foo
def foo
"foo"
end

end


# UnboundMethod `m' を生成
p m =...
...タンスをレシーバとする Method
class Bar < Foo
end

p m.bind(Bar.new) # => #<Method: Bar(Foo)#foo>


# モジュールのインスタンスメソッドの UnboundMethod の場合
module Foo
def foo
"foo"
end

end


# UnboundMethod `m' を生成
p m = Foo.instance_method(...
...:foo) # => #<UnboundMethod: Foo#foo>

# Foo をインクルードしたクラス Bar のインスタンスをレシーバと
# する Method オブジェクトを生成
class Bar
include
Foo
end

p m.bind(Bar.new) # => #<Method: Bar(Foo)#foo>
//}...
...:foo) # => #<UnboundMethod: Foo#foo>

# Foo をインクルードしたクラス Bar のインスタンスをレシーバと
# する Method オブジェクトを生成
class Bar
include
Foo
end

p m.bind(Bar.new) # => #<Method: Bar(Foo)#foo>
//}

@see UnboundMethod#bind_call...

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

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

...ram other 比較対象のモジュールやクラス

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

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

絞り込み条件を変える

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

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

...her 比較対象のモジュールやクラス

@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 # => f...

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

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

...

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

@see Module#<

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

module Prepended
prepend Awesome
end


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

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

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

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

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

...her 比較対象のモジュールやクラス

@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 # => t...

TSort#tsort -> Array (37.0)

頂点をトポロジカルソートして得られる配列を返します。 この配列は子から親に向かってソートされています。 すなわち、最初の要素は子を持たず、最後の要素は親を持ちません。

...を持ちません。

@raise TSort::Cyclic 閉路が存在するとき、発生します。

//emlist[使用例][ruby]{
require 'tsort'

class Hash
include
TSort
alias tsort_each_node each_key
def tsort_each_child(node, &block)
fetch(node).each(&block)
end

end


sorted = {1=>[2, 3], 2=>[...
<< 1 2 > >>