るりまサーチ

最速Rubyリファレンスマニュアル検索!
1079件ヒット [1-100件を表示] (0.041秒)
トップページ > クエリ:ruby[x] > クラス:Module[x] > クエリ:>[x]

別のキーワード

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

検索結果

<< 1 2 3 ... > >>

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

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

...@see 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 > Prep...
...ended # => true
Prepended > Awesome # => false

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

Module#ruby2_keywords(method_name, ...) -> nil (6232.0)

For the given method names, marks the method as passing keywords through a normal argument splat. This should only be called on methods that accept an argument splat (`*args`) but not explicit keywords or a keyword splat. It marks the method such that if the method is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the method to other methods.

...r
method, and only for backwards compatibility with Ruby versions before
2.7.

This method will probably be removed at some point, as it exists only
for backwards compatibility. As it does not exist in Ruby versions
before 2.7, check that the module responds to this method before calling
it. Also, b...
...aware that if this method is removed, the behavior of the
method will change so that it does not pass through keywords.

//emlist[例][ruby]{
module
Mod
def foo(meth, *args, &block)
send(:"do_#{meth}", *args, &block)
end
ruby
2_keywords(:foo) if respond_to?(:ruby2_keywords, true)
end
//}...

Module#<=>(other) -> Integer | nil (6107.0)

self と 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 Qux <=> Baz # => nil

p Baz <=> Object.new # => nil
//}...

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

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

...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 # => [Foo, Baz]
Foo >= Baz # => true
Baz >= Foo # => false

Foo >= Foo # => true
Foo >= Object # => ni...

Module#attr(*name) -> [Symbol] (119.0)

インスタンス変数読み取りのためのインスタンスメソッド name を定義します。

...ます。

//emlist[例][ruby]{
class User
attr :name # => [:name]
# 複数の名前を渡すこともできる
attr :id, :age # => [:id, :age]
end
//}

このメソッドで定義されるアクセスメソッドの定義は次の通りです。

//emlist[例][ruby]{
def name
@name
end
//}...
...た場合には、属性の書き込み用メソッド name= も同時に定義されます。
その定義は次の通りです。

//emlist[例][ruby]{
def name=(val)
@name = val
end
//}

第 2 引数 に true か false を指定する方法は非推奨です。

@param name String または Sym...

絞り込み条件を変える

Module#attr(name, false) -> [Symbol] (119.0)

インスタンス変数読み取りのためのインスタンスメソッド name を定義します。

...ます。

//emlist[例][ruby]{
class User
attr :name # => [:name]
# 複数の名前を渡すこともできる
attr :id, :age # => [:id, :age]
end
//}

このメソッドで定義されるアクセスメソッドの定義は次の通りです。

//emlist[例][ruby]{
def name
@name
end
//}...
...た場合には、属性の書き込み用メソッド name= も同時に定義されます。
その定義は次の通りです。

//emlist[例][ruby]{
def name=(val)
@name = val
end
//}

第 2 引数 に true か false を指定する方法は非推奨です。

@param name String または Sym...

Module#attr(name, true) -> [Symbol] (119.0)

インスタンス変数読み取りのためのインスタンスメソッド name を定義します。

...ます。

//emlist[例][ruby]{
class User
attr :name # => [:name]
# 複数の名前を渡すこともできる
attr :id, :age # => [:id, :age]
end
//}

このメソッドで定義されるアクセスメソッドの定義は次の通りです。

//emlist[例][ruby]{
def name
@name
end
//}...
...た場合には、属性の書き込み用メソッド name= も同時に定義されます。
その定義は次の通りです。

//emlist[例][ruby]{
def name=(val)
@name = val
end
//}

第 2 引数 に true か false を指定する方法は非推奨です。

@param name String または Sym...

Module#autoload(const_name, feature) -> nil (119.0)

定数 const_name を最初に参照した時に feature を Kernel.#require するように設定します。

...ruby]{
# ------- /tmp/foo.rb ---------
class Foo
class Bar
end
end
# ----- end of /tmp/foo.rb ----

class Foo
autoload :Bar, '/tmp/foo'
end
p Foo::Bar #=> Foo::Bar
//}

以下のようにモジュールを明示的にレシーバとして呼び出すこともできます。

//emlist[例][ruby...
...b ----

class Foo
end
Foo.autoload :Bar, '/tmp/foo'
p Foo::Bar #=> Foo::Bar
//}

以下のように、autoload したライブラリがネストした定数を定義しない場
合、NameError が発生します。

//emlist[例][ruby]{
# ------- /tmp/bar.rb ---------
class Bar
end
# ----- end of /...
...tmp/bar.rb ----

class Foo
autoload :Bar, '/tmp/bar.rb'
end
p Foo::Bar
#=> -:4:in `<main>': uninitialized constant Foo::Bar (NameError)
//}

@see Kernel.#autoload...

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

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

...ます。

@param mod Module のインスタンス( Enumerable など)を指定します。

@raise ArgumentError 継承関係が循環してしまうような include を行った場合に発生します。

//emlist[例][ruby]{
module
M
end
module
M2
include M
end
module
M
include M2
end
//}...
...ンクルードは多重継承の代わりに用いられており、 mix-in とも呼びます。

//emlist[例][ruby]{
class C
include FileTest
include Math
end

p C.ancestors

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

モジュールの機能追加は、クラスの継承関係の間に...
...ールのほうが
先に行われます
(上の例の Module#ancestors の結果がメソッド探索の順序です)。

同じモジュールを二回以上 include すると二回目以降は無視されます。

//emlist[例][ruby]{
module
M
end
class C1
include M
end
class C2 < C1
include...

Module.new -> Module (119.0)

名前の付いていないモジュールを新しく生成して返します。

...
モジュールのコンテキストでブロックを実行します。

//emlist[例][ruby]{
mod = Module.new
mod.module_eval {|m|
# ...
}
mod
//}

と同じです。
ブロックの実行は Module#initialize が行います。

ブロックを与えた場合も生成したモジュール...
...前は、
そのモジュールが代入されている定数名のいずれかです。

//emlist[例][ruby]{
m = Module.new
p m # => #<Module 0lx40198a54>
p m.name # => nil # まだ名前は未定
Foo = m
# m.name # ここで m.name を呼べば m の名前は "Fo...

絞り込み条件を変える

Module.new {|mod| ... } -> Module (119.0)

名前の付いていないモジュールを新しく生成して返します。

...
モジュールのコンテキストでブロックを実行します。

//emlist[例][ruby]{
mod = Module.new
mod.module_eval {|m|
# ...
}
mod
//}

と同じです。
ブロックの実行は Module#initialize が行います。

ブロックを与えた場合も生成したモジュール...
...前は、
そのモジュールが代入されている定数名のいずれかです。

//emlist[例][ruby]{
m = Module.new
p m # => #<Module 0lx40198a54>
p m.name # => nil # まだ名前は未定
Foo = m
# m.name # ここで m.name を呼べば m の名前は "Fo...
<< 1 2 3 ... > >>