るりまサーチ

最速Rubyリファレンスマニュアル検索!
11件ヒット [1-11件を表示] (0.121秒)
トップページ > クエリ:i[x] > クエリ:class[x] > クエリ:instance_delegate[x]

別のキーワード

  1. argf.class lines
  2. argf.class each_line
  3. argf.class each
  4. class new
  5. argf.class set_encoding

ライブラリ

モジュール

検索結果

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

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

...定します。キーは Symbol、
String かその配列で指定します。


例:

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

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