るりまサーチ

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

別のキーワード

  1. openssl t61string
  2. asn1 t61string
  3. matrix t
  4. t61string new
  5. fiddle type_size_t

検索結果

<< 1 2 3 ... > >>

Module#protected_method_defined?(name, inherit=true) -> bool (12207.0)

インスタンスメソッド name がモジュールに定義されており、 しかもその可視性が protected であるときに true を返します。 そうでなければ false を返します。

...ュールに定義されており、
しかもその可視性が protected であるときに true を返します。
そうでなければ false を返します。

@param name Symbol か String を指定します。
@param inherit 真を指定するとスーパークラスや include したモジ...
...e Module#method_defined?, Module#public_method_defined?, Module#private_method_defined?

//emlist[例][ruby]{
module
A
def method1() end
end
class B
protected
def method2() end
end
class C < B
include A
def method3() end
end

A.method_defined? :method1 #=> true
C.prot...
...ected_method_defined? "method1" #=> false
C.protected_method_defined? "method2" #=> true
C.protected_method_defined? "method2", true #=> true
C.protected_method_defined? "method2", false #=> false
C.method_defined? "method2" #=> true
//}...

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.

... 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, t...
...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.

T
his should only be used for methods that delegate keywords to another
method, and only for backwards compatibility with Ruby...
...re
2.7.

T
his 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, be aware that if this method is removed, the behavior of the
method wil...

Module#define_method(name, method) -> Symbol (6207.0)

インスタンスメソッド name を定義します。

...スタンスの上で BasicObject#instance_eval されます。

@param name メソッド名を String または Symbol を指定します。

@param method Proc、Method あるいは UnboundMethod の
いずれかのインスタンスを指定します。

@return メソッド名を表す Sy...
...します。

@raise TypeError method に同じクラス、サブクラス、モジュール以外のメソッ
ドを指定した場合に発生します。

//emlist[例][ruby]{
class Foo
def foo() p :foo end
define_method(:bar, instance_method(:foo))
end
Foo.new.bar # => :f...

Module#private_instance_methods(inherited_too = true) -> [Symbol] (6207.0)

そのモジュールで定義されている private メソッド名 の一覧を配列で返します。

...private メソッド名
の一覧を配列で返します。

@param inherited_too false を指定するとそのモジュールで定義されているメソッドのみ返します。

@see Object#private_methods, Module#instance_methods

//emlist[例][ruby]{
module
Foo
def foo; end
private de...
...f bar; end
end

module
Bar
include Foo

def baz; end
private def qux; end
end

Bar.private_instance_methods # => [:qux, :bar]
Bar.private_instance_methods(false) # => [:qux]
//}...

Module#const_missing(name) (6123.0)

定義されていない定数を参照したときに Ruby インタプリタが このメソッドを呼びます。

... Ruby インタプリタが
このメソッドを呼びます。

@param name 参照した定数名の Symbol

@raise NameError このメソッドを呼び出した場合、デフォルトで発生する例外


//emlist[例][ruby]{
class Foo
def Foo.const_missing(id)
warn "undefined constant...
...#{id.inspect}"
end

Bar
end
Foo::Bar

# => undefined constant :Bar
# undefined constant :Bar
//}...

絞り込み条件を変える

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

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

...します。

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

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

//emlist[例][ruby]{
def name
@name
end
/...
...ます。
その定義は次の通りです。

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

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

@param name String または Symbol で指定します。
@return 定義されたメソッド名を Symbol の配列...

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

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

...します。

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

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

//emlist[例][ruby]{
def name
@name
end
/...
...ます。
その定義は次の通りです。

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

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

@param name String または Symbol で指定します。
@return 定義されたメソッド名を Symbol の配列...

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

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

...します。

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

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

//emlist[例][ruby]{
def name
@name
end
/...
...ます。
その定義は次の通りです。

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

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

@param name String または Symbol で指定します。
@return 定義されたメソッド名を Symbol の配列...

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

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

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

const_name が autoload 設定されていて、まだ定義されてない(ロードされていない)ときは、
autoload する対象を置き換えます。
const_name が(autoloadで...
...m const_name String または Symbol で指定します。
なお、const_name には、"::" 演算子を含めることはできません。
つまり、self の直下に定義された定数しか指定できません。

@param feature Kernel.#require と同様な方法で autoload...
...ist[例][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[...

Module#alias_method(new, original) -> Symbol (6113.0)

メソッドの別名を定義します。

...メソッドの別名を定義します。

//emlist[例][ruby]{
module
Kernel
alias_method :hoge, :puts # => :hoge
alias_method "foo", :puts # => :foo
end
//}

alias との違いは以下の通りです。

* メソッド名は String または Symbol で指定します
* グローバル...
...。String または Symbol で指定します。

@param original 元のメソッド名。String または Symbol で指定します。

@return 作成したエイリアスのメソッド名を表す Symbol を返します。

@see d:spec/def#alias

//emlist[例][ruby]{
module
Kernel
alias_method...
...:foo, :puts
end

foo "bar" # bar
//}...

絞り込み条件を変える

Module#alias_method(new, original) -> self (6113.0)

メソッドの別名を定義します。

...メソッドの別名を定義します。

//emlist[例][ruby]{
module
Kernel
alias_method :hoge, :puts # => Kernel
end
//}

alias との違いは以下の通りです。

* メソッド名は String または Symbol で指定します
* グローバル変数の別名をつけることはで...
...しいメソッド名。String または Symbol で指定します。

@param original 元のメソッド名。String または Symbol で指定します。

@return self を返します。

@see d:spec/def#alias

//emlist[例][ruby]{
module
Kernel
alias_method :foo, :puts
end

foo "bar" # bar
//}...

Module#append_features(module_or_class) -> self (6113.0)

モジュール(あるいはクラス)に self の機能を追加します。

...ドは Module#include の実体であり、
include を Ruby で書くと以下のように定義できます。

//emlist[例][ruby]{
def include(*modules)
module
s.reverse_each do |mod|
# append_features や included はプライベートメソッドなので
# 直接 mod.append_features(...
...self) などとは書けない
mod.__send__(:append_features, self)
mod.__send__(:included, self)
end
end
//}

@see Module#included...
<< 1 2 3 ... > >>