るりまサーチ

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

別のキーワード

  1. matrix l
  2. kernel $-l
  3. _builtin $-l
  4. lupdecomposition l
  5. l

ライブラリ

検索結果

<< 1 2 3 ... > >>

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

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

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

継承関係にないクラス同士の比較では
nil を返します。

@param other 比較対象のモジュールやクラ...
...@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#>=(other) -> bool | nil (9301.0)

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

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

継承関係にないクラス同士の比較では
nil を返します。

@param other 比較対象のモジュールやクラ...
...e 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 # => nil...

Module.used_modules -> [Module] (9301.0)

現在のスコープで using されているすべてのモジュールを配列で返します。 配列内のモジュールの順番は未定義です。

...ープで using されているすべてのモジュールを配列で返します。
配列内のモジュールの順番は未定義です。

//emlist[例][ruby]{
module
A
refine Object do
end
end

module
B
refine Object do
end
end

using A
using B
p Module.used_modules
#=> [B, A]
//}...

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

self と other の継承関係を比較します。

...elf と other の継承関係を比較します。

self と other を比較して、
self が other の子孫であるとき -1、
同一のクラス/モジュールのとき 0、
self が other の先祖であるとき 1
を返します。

継承関係にないクラス同士の比較では
nil...
...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 Qux <=> Baz...
...# => nil

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

Module#class_variable_defined?(name) -> bool (9201.0)

name で与えられた名前のクラス変数がモジュールに存在する場合 true を 返します。

...name Symbol か String を指定します。

//emlist[例][ruby]{
class Fred
@@foo = 99
end
Fred.class_variable_defined?(:@@foo) #=> true
Fred.class_variable_defined?(:@@bar) #=> false
Fred.class_variable_defined?('@@foo') #=> true
Fred.class_variable_defined?('@@bar') #=> false
//}...

絞り込み条件を変える

Module#class_variable_get(name) -> object (9201.0)

クラス/モジュールに定義されているクラス変数 name の値を返します。

...の値を返します。

@param name String または Symbol を指定します。

@raise NameError クラス変数 name が定義されていない場合、発生します。

//emlist[例][ruby]{
class Fred
@@foo = 99
end

def Fred.foo
class_variable_get(:@@foo)
end

p Fred.foo #=> 99
//}...

Module#class_variable_set(name, val) -> object (9201.0)

クラス/モジュールにクラス変数 name を定義して、その値として val をセットします。val を返します。

...val をセットします。val を返します。

@param name String または Symbol を指定します。

//emlist[例][ruby]{
class Fred
@@foo = 99
def foo
@@foo
end
end

def Fred.foo(val)
class_variable_set(:@@foo, val)
end

p Fred.foo(101) # => 101
p Fred.new.foo # => 101
/...

Module#class_variables(inherit = true) -> [Symbol] (9201.0)

クラス/モジュールに定義されているクラス変数の名前の配列を返します。

...rit false を指定しない場合はスーパークラスやインクルードして
いるモジュールのクラス変数を含みます。

//emlist[例][ruby]{
class One
@@var1 = 1
end
class Two < One
@@var2 = 2
end
One.class_variables # => [:@@var1]
Two.class_variables...
...# => [:@@var2, :@@var1]
Two.class_variables(false) # => [:@@var2]
//}

@see Module.constants, Kernel.#local_variables, Kernel.#global_variables, Object#instance_variables, Module#constants...

Module#included_modules -> [Module] (9201.0)

self にインクルードされているモジュールの配列を返します。

...self にインクルードされているモジュールの配列を返します。

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

module
Outer
include Mixin
end

Mixin.included_modules #=> []
Outer.included_modules #=> [Mixin]
//}

@see Module#ancestors...

Module#module_function() -> nil (9201.0)

メソッドをモジュール関数にします。

...引数が与えられた時には配列にまとめて返します。
引数なしの時は nil を返します。

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

=== 注意
module
_function はメソッドに「モジュール関数」という属性をつけるメ
ソッド...
...もモジュール関数の別名は定義できません。

//emlist[例][ruby]{
module
M
def foo
p "foo"
end
module
_function :foo
alias bar foo
end

M.foo # => "foo"
M.bar # => undefined method `bar' for Foo:Module (NoMethodError)
//}

このコードでは、モジュール関数...
...けるには、
以下のように、先に別名を定義してから
それぞれをモジュール関数にしなければいけません。

//emlist[例][ruby]{
module
M
def foo
p "foo"
end

alias bar foo
module
_function :foo, :bar
end

M.foo # => "foo"
M.bar # => "foo"
//}...

絞り込み条件を変える

<< 1 2 3 ... > >>