ライブラリ
- ビルトイン (12)
- delegate (12)
- forwardable (24)
クラス
- Module (12)
モジュール
- Forwardable (24)
- Kernel (12)
キーワード
- DelegateClass (12)
-
instance
_ delegate (12) -
ruby2
_ keywords (12)
検索結果
先頭4件
-
Forwardable
# delegate(hash) -> () (24227.0) -
メソッドの委譲先を設定します。
...String かその配列で指定します。
//emlist[例][ruby]{
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"
zap.last # => "baz"
//}... -
Kernel
# DelegateClass(superclass) -> object (20219.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) -> () (12227.0) -
メソッドの委譲先を設定します。
...String かその配列で指定します。
//emlist[例][ruby]{
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"
zap.last # => "baz"
//}... -
Module
# ruby2 _ keywords(method _ name , . . . ) -> nil (119.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......ent 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 meth......od 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. As it does not exist in Ruby ve...