44件ヒット
[1-44件を表示]
(0.060秒)
ライブラリ
- forwardable (44)
キーワード
-
def
_ delegator (11) -
def
_ instance _ delegator (11) - delegate (11)
-
instance
_ delegate (11)
検索結果
先頭4件
-
Forwardable
# def _ delegator(accessor , method , ali = method) -> () (13.0) -
メソッドの委譲先を設定します。
...require 'forwardable'
class MyQueue
extend Forwardable
attr_reader :queue
def initialize
@queue = []
end
def_delegator :@queue, :push, :mypush
end
q = MyQueue.new
q.mypush 42
q.queue # => [42]
q.push 23 # => NoMethodError
@see Forwardable#def_delegato... -
Forwardable
# def _ instance _ delegator(accessor , method , ali = method) -> () (13.0) -
メソッドの委譲先を設定します。
...require 'forwardable'
class MyQueue
extend Forwardable
attr_reader :queue
def initialize
@queue = []
end
def_delegator :@queue, :push, :mypush
end
q = MyQueue.new
q.mypush 42
q.queue # => [42]
q.push 23 # => NoMethodError
@see Forwardable#def_delegato... -
Forwardable
# delegate(hash) -> () (13.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 # =>... -
Forwardable
# instance _ delegate(hash) -> () (13.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 # =>...