1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
-- forwatable.rb
$Release Version: 1.1 $
$Revision$
$Date$
= Forwardable
���饹���Ф���åɤΰѾ���ǽ��������ޤ�.
== �Ȥ���
���饹���Ф���extend���ƻȤ��ޤ�.
class Foo
extend Forwardable
def_delegators("@out", "printf", "print")
def_delegators(:@in, :gets)
def_delegator(:@contents, :[], "content_at")
end
f = Foo.new
f.printf ...
f.gets
f.content_at(1)
== ��å�
--- Forwardable#def_instance_delegators(accessor, *methods)
((|methods|))���Ϥ��줿��åɤΥꥹ�Ȥ�((|accessor��|))�Ѿ�����
�褦�ˤ��ޤ�.
--- Forwardable#def_instance_delegator(accessor, method, ali = method)
((||method|))���Ϥ��줿��åɤ�((|accessor|))�˰Ѿ�����褦�ˤ�
�ޤ�. ((|ali|))�������Ȥ����Ϥ��줿�Ȥ���, ��å�((|ali|))���Ƥ�
�줿�Ȥ��ˤ�, ((|accessor|))���Ф�((|method|))��ƤӽФ��ޤ�.
--- Forwardable#def_delegators(accessor, *methods)
((|Forwardable#def_instance_delegators|))����̾�Ǥ�.
--- Forwardable#def_delegator(accessor, method, ali = method)
((|Forwardable#def_instance_delegator|))����̾�Ǥ�.
= SingleForwardable
���֥������Ȥ��Ф�, ��åɤΰѾ���ǽ��������ޤ�.
== �Ȥ���
���֥������Ȥ��Ф���((|extend|))���ƻȤ��ޤ�.
g = Goo.new
g.extend SingleForwardable
g.def_delegator("@out", :puts)
g.puts ...
== ��å�
--- SingleForwardable#def_singleton_delegators(accessor, *methods)
((|methods|))���Ϥ��줿��åɤΥꥹ�Ȥ�((|accessor|))�˰Ѿ�����
�褦�ˤ��ޤ�.
--- SingleForwardable#def_singleton_delegator(accessor, method, ali = method)
((|method|))���Ϥ��줿��åɤ�((|accessor|))�˰Ѿ�����褦�ˤ���
��. ((|ali|))�������Ȥ����Ϥ��줿�Ȥ���, ��å�((|ali|))���ƤФ�
���Ȥ��ˤ�, ((|accessor|))���Ф�((|method|))��ƤӽФ��ޤ�.
--- SingleForwardable#def_delegators(accessor, *methods)
((|SingleForwardable#def_singleton_delegators|))����̾�Ǥ�.
--- SingleForwardable#def_delegator(accessor, method, ali = method)
((|SingleForwardable#def_singleton_delegator|))����̾�Ǥ�.
|