るりまサーチ

最速Rubyリファレンスマニュアル検索!
724件ヒット [201-300件を表示] (0.117秒)

別のキーワード

  1. string b
  2. _builtin b
  3. b string
  4. b _builtin

検索結果

<< < 1 2 3 4 5 ... > >>

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

...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 argument...
...s will be passed through the method to
other methods.

This should only be used for methods that delegate keywords to another
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...
...exist in Ruby versions
b
efore 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)
se...

Module#instance_method(name) -> UnboundMethod (114.0)

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

...化した UnboundMethod を返します。

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

@raise NameError self に存在しないメソッドを指定した場合に発生します。

@see Module#public_instance_method, Object#method

//emlist[例][ruby]{
class Inte...
...d(:do_a),
"d" => instance_method(:do_d),
"e" => instance_method(:do_e),
"v" => instance_method(:do_v)
}
def interpret(string)
string.each_char {|b| Dispatcher[b].bind(self).call }
end
end

interpreter = Interpreter.new
interpreter.interpret('dave')
# => Hello there, Dave!
//}...

Module#method_defined?(name, inherit=true) -> bool (114.0)

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

...public または protected であるときに
true を返します。

@param name Symbol か String を指定します。
@param inherit 真を指定するとスーパークラスや include したモジュールで
定義されたメソッドも対象になります。

@see Module#public_...
...efined?, Module#private_method_defined?, Module#protected_method_defined?

//emlist[例][ruby]{
module
A
def method1() end
def protected_method1() end
protected :protected_method1
end
class B
def method2() end
def private_method2() end
private :private_method2
end
class C < B
inclu...

Module#private_method_defined?(name, inherit=true) -> bool (114.0)

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

...

@param name Symbol か String を指定します。
@param inherit 真を指定するとスーパークラスや include したモジュールで
定義されたメソッドも対象になります。

@see Module#method_defined?, Module#public_method_defined?, Module#protected_method_de...
...fined?

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

A.method_defined? :method1 #=> true
C.private_method_defined? "method1" #=> false
C.private_method_defined? "method2"...

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

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

...

@param name Symbol か String を指定します。
@param inherit 真を指定するとスーパークラスや include したモジュールで
定義されたメソッドも対象になります。

@see Module#method_defined?, Module#public_method_defined?, Module#private_method_defi...
...ned?

//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.protected_method_defined? "method1" #=> false
C.protected_method_defined? "meth...

絞り込み条件を変える

Module#private(name) -> String | Symbol (108.0)

メソッドを private に設定します。

...は Symbol を指定します。
@param names 0 個以上の String または Symbol を Array で指定します。

@raise NameError 存在しないメソッド名を指定した場合に発生します。

//emlist[例][ruby]{
class Foo
def foo1() 1 end # デフォルトでは public
pri...
...vate # 可視性を private に変更
def foo2() 2 end # foo2 は private メソッド
end

foo = Foo.new
p foo.foo1 # => 1
p foo.foo2 # => private method `foo2' called for #<Foo:0x401b7628> (NoMethodError)
//}...

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

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

...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 Baz < Foo # => true
p Baz < Qux # => nil
p Baz > Qux # => nil

p Foo < Object.new # => in `<': compared with non class/module (TypeError)...

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

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

...@see Module#<

//emlist[例][ruby]{
module
Foo; end
module
Bar
include Foo
end
module
Baz
prepend Foo
end

B
ar.ancestors # => [Bar, Foo]
Foo <= Bar # => false
B
ar <= Foo # => true

B
az.ancestors # => [Foo, Baz]
Foo <= Baz # => false
B
az <= Foo # => true

Foo <= Foo # => true
Foo <= Object # =>...

Module#===(obj) -> bool (102.0)

指定された obj が self かそのサブクラスのインスタンスであるとき真を返します。 また、obj が self をインクルードしたクラスかそのサブクラスのインスタンスである場合にも 真を返します。上記のいずれでもない場合に false を返します。

...指定された obj が self かそのサブクラスのインスタンスであるとき真を返します。
また、obj が self をインクルードしたクラスかそのサブクラスのインスタンスである場合にも
真を返します。上記のいずれでもない場合に fa...
...言い替えると obj.kind_of?(self) が true の場合、 true を返します。

このメソッドは主に case 文での比較に用いられます。
case ではクラス、モジュールの所属関係をチェックすることになります。

//emlist[例][ruby]{
str = String.new
ca...
...se str
when String # String === str を評価する
p true # => true
end
//}

@param obj 任意のオブジェクト

@see Object#kind_of?, Object#instance_of?, d:spec/control#case...
<< < 1 2 3 4 5 ... > >>