るりまサーチ

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

別のキーワード

  1. _builtin end
  2. ripper end_seen?
  3. _builtin exclude_end?
  4. _builtin end_with?
  5. io seek_end

ライブラリ

クラス

モジュール

キーワード

検索結果

Forwardable#delegate(hash) -> () (18127.0)

メソッドの委譲先を設定します。

...ます。


例:

require 'forwardable'
class Zap
extend Forwardable
delegate
:length => :@str
delegate
[:first, :last] => :@arr
def initialize
@arr = %w/foo bar baz/
@str = "world"
end

end


zap = Zap.new
zap.length # => 5
zap.first # => "foo"...

Kernel#DelegateClass(superclass) -> object (14119.0)

クラス superclass のインスタンスへメソッドを委譲するクラスを定義し、 そのクラスを返します。

...ラスを定義し、
そのクラスを返します。

@param superclass 委譲先となるクラス

例:

//emlist{
require 'delegate'

class ExtArray < DelegateClass(Array)
def initialize
super([])
end

end

a = ExtArray.new
p a.class # => ExtArray
a.push 25
p a # => [25]
//}...

Forwardable#instance_delegate(hash) -> () (6127.0)

メソッドの委譲先を設定します。

...ます。


例:

require 'forwardable'
class Zap
extend Forwardable
delegate
:length => :@str
delegate
[:first, :last] => :@arr
def initialize
@arr = %w/foo bar baz/
@str = "world"
end

end


zap = Zap.new
zap.length # => 5
zap.first # => "foo"...

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

...s interpreted as
keywords. In other words, keywords 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 po...
...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

ruby2_keywords(:foo) if respond_to?(:ruby2_keywords, true)
end

//}...

Proc#ruby2_keywords -> proc (19.0)

Marks the proc as passing keywords through a normal argument splat. This should only be called on procs that accept an argument splat (`*args`) but not explicit keywords or a keyword splat. It marks the proc such that if the proc 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 proc to other methods.

...t is interpreted as keywords. In other words, keywords will
be passed through the proc to other methods.

This should only be used for procs 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 po...
...so, be aware that if this method is removed, the behavior of the
proc will change so that it does not pass through keywords.

//emlist[][ruby]{
module Mod
foo = ->(meth, *args, &block) do
send(:"do_#{meth}", *args, &block)
end

foo.ruby2_keywords if foo.respond_to?(:ruby2_keywords)
end

//}...

絞り込み条件を変える