るりまサーチ

最速Rubyリファレンスマニュアル検索!
1116件ヒット [501-600件を表示] (0.104秒)

別のキーワード

  1. module attr
  2. module public
  3. module private
  4. module protected
  5. module new

ライブラリ

検索結果

<< < ... 4 5 6 7 8 ... > >>

Module#include?(mod) -> bool (21014.0)

self かその親クラス / 親モジュールがモジュール mod を インクルードしていれば true を返します。

...クラス / 親モジュールがモジュール mod を
インクルードしていれば true を返します。

@param mod Module を指定します。

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

p C1.include?(M) # => true
p C2.include?(M) # => true
//}...

Module#private_constant(*name) -> self (21014.0)

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

...se NameError 存在しない定数を指定した場合に発生します。

@return self を返します。

@see Module#public_constant, Object#untrusted?

//emlist[例][ruby]{
module
Foo
BAR = 'bar'
class Baz; end
QUX = 'qux'
class Quux; end

private_constant :QUX
private_constant :Q...
...

@raise NameError 存在しない定数を指定した場合に発生します。

@return self を返します。

@see Module#public_constant

//emlist[例][ruby]{
module
Foo
BAR = 'bar'
class Baz; end
QUX = 'qux'
class Quux; end

private_constant :QUX
private_constant :Quux
end

F...

Module#public_instance_method(name) -> UnboundMethod (21014.0)

self の public インスタンスメソッド name をオブジェクト化した UnboundMethod を返します。

...として与えると発生します。

//emlist[例][ruby]{
Kernel.public_instance_method(:object_id) #=> #<UnboundMethod: Kernel#object_id>
Kernel.public_instance_method(:p) # method `p' for module `Kernel' is private (NameError)
//}

@see Module#instance_method,Object#public_method...

Module#ruby2_keywords(method_name, ...) -> nil (21014.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.

...st in Ruby versions
before 2.7, check that the module responds to this method before calling
it. Also, be 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(:...

Module#undef_method(*name) -> self (21014.0)

このモジュールのインスタンスメソッド name を未定義にします。

...ng または Symbol で与えられることです。

//emlist[例][ruby]{
module
M1
def foo
end
def self.moo
undef foo
end
end
M1.instance_methods false #=> ["foo"]
M1.moo
M1.instance_methods false #=> []
module
M2
def foo
end
def self.moo
undef_method :foo
end
end
M2.insta...

絞り込み条件を変える

Module#<=>(other) -> Integer | nil (21008.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 # =>...

Module#const_added(name) -> () (21008.0)

定数 name が追加された時にインタプリタがこのメソッドを呼び出します。

...定数 name が追加された時にインタプリタがこのメソッドを呼び出します。

//emlist[][ruby]{
module
Chatty
def self.const_added(const_name)
super
puts "Added #{const_name.inspect}"
end
FOO = 1
end
# => Added :FOO
//}...

Module#const_set(name, value) -> object (21008.0)

モジュールに name で指定された名前の定数を value とい う値として定義し、value を返します。

...@param name Symbol,String で定数の名前を指定します。
@param value セットしたい値を指定します。

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

# Symbolを指定した場合
Foo.const_set(:FOO, 123)
Foo::FOO # => 123

# Stringを指定した場合
Foo.const_set('BAR', 'abc')
Foo:...

Module#const_source_location(name, inherited = true) -> [String, Integer] (21008.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 # 定数を...
...] -- 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#extend_object(obj) -> object (21008.0)

Object#extend の実体です。オブジェクトにモジュールの機能を追加します。

...機能を追加します。

Object#extend は、Ruby で書くと以下のように定義できます。

//emlist[例][ruby]{
def extend(*modules)
module
s.reverse_each do |mod|
# extend_object や extended はプライベートメソッドなので
# 直接 mod.extend_object(self) など...
...では、self に定義されて
いるインスタンスメソッドを obj の特異メソッドとして追加します。

@param obj self の機能を追加するオブジェクトを指定します。

@return obj で指定されたオブジェクトを返します。

@see Module#extended...

絞り込み条件を変える

<< < ... 4 5 6 7 8 ... > >>