File: ref_c_object.xml

package info (click to toggle)
rubybook 0.2.1-1
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k, lenny, squeeze, wheezy
  • size: 4,248 kB
  • ctags: 1,042
  • sloc: xml: 60,486; makefile: 25
file content (1187 lines) | stat: -rw-r--r-- 32,456 bytes parent folder | download | duplicates (3)
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
<ppdoc>
<copyright>
    Copyright (c) 2001 by Addison Wesley Longman.  This
    material may be distributed only subject to the terms and
    conditions set forth in the Open Publication License, v1.0 or
    later (the latest version is presently available at
    http://www.opencontent.org/openpub/).
</copyright>
<class name="Object" super="" type="class">
    <subclasses>Array, Binding, Continuation,
    Data, Dir, Exception, FalseClass, File::Stat, Hash, IO,
    MatchingData, Method, Module, NilClass, Numeric, Proc, Range,
    Regexp, String, Struct, Symbol, Thread, Time, TrueClass</subclasses>
<p/>
  <classname>Object</classname> is the parent class of all classes in Ruby. Its methods
  are therefore available to all objects unless explicitly
  overridden.
<p/>
  <classname>Object</classname> mixes in the <modulename>Kernel</modulename> module, making the built-in
  kernel functions globally accessible. Although the instance methods
  of <classname>Object</classname> are defined by the <modulename>Kernel</modulename> module, we have chosen
  to document them here for clarity.
<p/>
  In the descriptions that follow, the
  parameter <obj>aSymbol</obj> refers to a symbol, which is either a
  quoted string or a <classname>Symbol</classname> (such as <tt>:name</tt>).
<p/>
  <methods type="instance">
        <method name="==" ref="_eq_eq">
      <callseq>
        <obj>obj</obj> == <obj>anObject</obj>
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Equality---At the <classname>Object</classname> level, <tt>==</tt> returns <const>true</const> only if
      <obj>obj</obj> and <obj>anObject</obj> are the same object. Typically, this
      method is overridden in descendent classes to provide
      class-specific meaning.
<p/>
      </desc>
    </method>
<p/>
        <method name="===" ref="_eq_eq_eq">
      <callseq>
        <obj>obj</obj> === <obj>anObject</obj>
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Case Equality---A synonym for <cim><file>object</file><front>Object</front><back>==</back><mref>_eq_eq</mref></cim>, but typically overridden by
      descendents to provide meaningful semantics in <tt>case</tt>
      statements.
<p/>
      </desc>
    </method>
<p/>
        <method name="=~" ref="_eq_sd">
      <callseq>
        <obj>obj</obj> =~ <obj>anObject</obj>
        <returns><const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Pattern Match---Overridden by descendents (notably <classname>Regexp</classname>
      and <classname>String</classname>) to provide meaningful
      pattern-match semantics.
<p/>
      </desc>
    </method>
<p/>
        <method name="__id__" ref="__id__">
      <callseq>
        <obj>obj</obj>.__id__
        <returns><obj>aFixnum</obj></returns>
      </callseq>
      <desc>
<p/>
      Synonym for <cim><file>object</file><front>Object</front><back>id</back><mref>id</mref></cim>.
<p/>
      </desc>
    </method>
<p/>
        <method name="__send__" ref="__send__">
      <callseq>
        <obj>obj</obj>.__send__(
        <obj>aSymbol</obj> <optn>, <obj>args</obj></optn> ) <returns><obj>anObject</obj></returns>
      </callseq>
      <desc>
<p/>
      Synonym for <cim><file>object</file><front>Object</front><back>send</back><mref>send</mref></cim>.
<p/>
      </desc>
    </method>
<p/>
        <method name="class" ref="class">
      <callseq>
        <obj>obj</obj>.class <returns><obj>aClass</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns the class of <obj>obj</obj> (synonym for <cim><file>object</file><front>Object</front><back>type</back><mref>type</mref></cim>). 
<p/>
      </desc>
    </method>
<p/>
        <method name="clone" ref="clone">
      <callseq>
        <obj>obj</obj>.clone <returns><obj>anObject</obj></returns>
      </callseq>
      <desc>
<p/>
      Produces a shallow copy of <obj>obj</obj>---the instance variables of <obj>obj</obj>
      are copied, but not the objects they reference. 
      Copies the frozen and tainted state of <obj>obj</obj>. See also the
      discussion under <cim><file>object</file><front>Object</front><back>dup</back><mref>dup</mref></cim>.
<p/>
<codefragment>
<fullcode><![CDATA[         class Klass
            attr_accessor :str
         end
         s1 = Klass.new
         s1.str = "Hello"
         s2 = s1.clone
         s2.str[1,4] = "i"
         s1.inspect
         s2.inspect
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>class<nbsp/>Klass</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/><nbsp/>attr_accessor<nbsp/>:str</tt></td>
</tr>
<tr>
<td colspan="3"><tt>end</tt></td>
</tr>
<tr>
  <td><tt>s1<nbsp/>=<nbsp/>Klass.new</tt></td>
  <td>&#187;</td>
  <td><tt>#&lt;Klass:0x4018d234&gt;</tt></td>
</tr>
<tr>
  <td><tt>s1.str<nbsp/>=<nbsp/>"Hello"</tt></td>
  <td>&#187;</td>
  <td><tt>"Hello"</tt></td>
</tr>
<tr>
  <td><tt>s2<nbsp/>=<nbsp/>s1.clone</tt></td>
  <td>&#187;</td>
  <td><tt>#&lt;Klass:0x4018d194<nbsp/><nbsp/>@str="Hello"&gt;</tt></td>
</tr>
<tr>
  <td><tt>s2.str[1,4]<nbsp/>=<nbsp/>"i"</tt></td>
  <td>&#187;</td>
  <td><tt>"i"</tt></td>
</tr>
<tr>
  <td><tt>s1.inspect</tt></td>
  <td>&#187;</td>
  <td><tt>"#&lt;Klass:0x4018d234<nbsp/><nbsp/>@str=\"Hi\"&gt;"</tt></td>
</tr>
<tr>
  <td><tt>s2.inspect</tt></td>
  <td>&#187;</td>
  <td><tt>"#&lt;Klass:0x4018d194<nbsp/><nbsp/>@str=\"Hi\"&gt;"</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="display" ref="display">
      <callseq>
        <obj>obj</obj>.display( <obj>port</obj>=<var>$&gt;</var> )
        <returns><tt>nil</tt></returns>
      </callseq>
      <desc>
<p/>
      Prints <obj>obj</obj> on the given port (default <var>$&gt;</var>). Equivalent 
      to:
<p/>
<codefragment>
<alltt><fullcode><![CDATA[        def display(port=$>)
          port.write self
        end
]]></fullcode>
def<nbsp/>display(port=$&gt;)
<nbsp/><nbsp/>port.write<nbsp/>self
end
</alltt>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="dup" ref="dup">
      <callseq>
        <obj>obj</obj>.dup <returns><obj>anObject</obj></returns>
      </callseq>
      <desc>
<p/>
      Produces a shallow copy      
      of <obj>obj</obj>---the instance variables of <obj>obj</obj>
      are copied, but not the objects they reference. <meth>dup</meth>
      copies the tainted state of <obj>obj</obj>. See also the
      discussion under <cim><file>object</file><front>Object</front><back>clone</back><mref>clone</mref></cim>.
      In general,
      <meth>clone</meth> and <meth>dup</meth> may have different semantics in
      descendent classes. While <meth>clone</meth> is used to duplicate an 
      object, including its internal state, <meth>dup</meth> typically
      uses the class of the descendent object to create the new instance.
<p/>
      </desc>
    </method>
<p/>
        <method name="eql?" ref="eql_qm">
      <callseq>
        <obj>obj</obj>.eql?( <obj>anObject</obj> )
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if <obj>obj</obj> and <obj>anObject</obj> have the
      same value. Used by <classname>Hash</classname> to test
      members for equality. For objects of class <classname>Object</classname>,
      <meth>eql?</meth> is synonymous with <meth>==</meth>. Subclasses
      normally continue this tradition, but there are
      exceptions. <classname>Numeric</classname> types, for example, perform type
      conversion across <meth>==</meth>, but not across <meth>eql?</meth>, so:
<p/>
<codefragment>
<fullcode><![CDATA[        1 == 1.0
        1.eql? 1.0
]]></fullcode><rubycode>
<tr>
  <td><tt>1<nbsp/>==<nbsp/>1.0</tt></td>
  <td>&#187;</td>
  <td><tt>true</tt></td>
</tr>
<tr>
  <td><tt>1.eql?<nbsp/>1.0</tt></td>
  <td>&#187;</td>
  <td><tt>false</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="equal?" ref="equal_qm">
      <callseq>
        <obj>obj</obj>.equal?( <obj>anObject</obj> )
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if <obj>obj</obj> and <obj>anObject</obj> have the
      same object ID. This method should
      not be overridden by subclasses.
<p/>
<codefragment>
<fullcode><![CDATA[         a = [ 'cat', 'dog' ]
         b = [ 'cat', 'dog' ]
         a == b
         a.id == b.id
         a.eql?(b)
         a.equal?(b)
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>a<nbsp/>=<nbsp/>[<nbsp/>'cat',<nbsp/>'dog'<nbsp/>]</tt></td>
</tr>
<tr>
<td colspan="3"><tt>b<nbsp/>=<nbsp/>[<nbsp/>'cat',<nbsp/>'dog'<nbsp/>]</tt></td>
</tr>
<tr>
  <td><tt>a<nbsp/>==<nbsp/>b</tt></td>
  <td>&#187;</td>
  <td><tt>true</tt></td>
</tr>
<tr>
  <td><tt>a.id<nbsp/>==<nbsp/>b.id</tt></td>
  <td>&#187;</td>
  <td><tt>false</tt></td>
</tr>
<tr>
  <td><tt>a.eql?(b)</tt></td>
  <td>&#187;</td>
  <td><tt>true</tt></td>
</tr>
<tr>
  <td><tt>a.equal?(b)</tt></td>
  <td>&#187;</td>
  <td><tt>false</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="extend" ref="extend">
      <callseq>
                <obj>obj</obj>.extend( <optn><obj>aModule</obj></optn> )
        <returns><obj>obj</obj></returns>
      </callseq>
      <desc>
<p/>
      Adds to <obj>obj</obj> the instance methods from each module given as a parameter.
<p/>
<codefragment>
<fullcode><![CDATA[         module Mod
           def hello
             "Hello from Mod.\n"
           end
         end
         
         class Klass
           def hello
             "Hello from Klass.\n"
           end           
         end
         
         k = Klass.new
         k.hello
         k.extend(Mod)
         k.hello
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>module<nbsp/>Mod</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>def<nbsp/>hello</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/><nbsp/><nbsp/>"Hello<nbsp/>from<nbsp/>Mod.\n"</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>end</tt></td>
</tr>
<tr>
<td colspan="3"><tt>end</tt></td>
</tr>
<tr>
<td colspan="3"><tt></tt></td>
</tr>
<tr>
<td colspan="3"><tt>class<nbsp/>Klass</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>def<nbsp/>hello</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/><nbsp/><nbsp/>"Hello<nbsp/>from<nbsp/>Klass.\n"</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>end</tt></td>
</tr>
<tr>
<td colspan="3"><tt>end</tt></td>
</tr>
<tr>
<td colspan="3"><tt></tt></td>
</tr>
<tr>
<td colspan="3"><tt>k<nbsp/>=<nbsp/>Klass.new</tt></td>
</tr>
<tr>
  <td><tt>k.hello</tt></td>
  <td>&#187;</td>
  <td><tt>"Hello<nbsp/>from<nbsp/>Klass.\n"</tt></td>
</tr>
<tr>
  <td><tt>k.extend(Mod)</tt></td>
  <td>&#187;</td>
  <td><tt>#&lt;Klass:0x4018d414&gt;</tt></td>
</tr>
<tr>
  <td><tt>k.hello</tt></td>
  <td>&#187;</td>
  <td><tt>"Hello<nbsp/>from<nbsp/>Mod.\n"</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="freeze" ref="freeze">
      <callseq>
        <obj>obj</obj>.freeze <returns><obj>obj</obj></returns>
      </callseq>
      <desc>
<p/>
      Prevents further modifications to <obj>obj</obj>. A <exception>TypeError</exception>
      will be raised if modification is attempted. There is no way to
      unfreeze a frozen object.
      See also <cim><file>object</file><front>Object</front><back>frozen?</back><mref>frozen_qm</mref></cim>.
<p/>
<codefragment>
<alltt><fullcode><![CDATA[        a = [ "a", "b", "c" ]
        a.freeze
        a << "z"
]]></fullcode>
a<nbsp/>=<nbsp/>[<nbsp/>"a",<nbsp/>"b",<nbsp/>"c"<nbsp/>]
a.freeze
a<nbsp/>&lt;&lt;<nbsp/>"z"
</alltt>
</codefragment>
<em>produces:</em>
<codefragment><alltt>
prog.rb:3:in<nbsp/>`&lt;&lt;':<nbsp/>can't<nbsp/>modify<nbsp/>frozen<nbsp/>array<nbsp/>(TypeError)
	from<nbsp/>prog.rb:3
</alltt>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="frozen?" ref="frozen_qm">
      <callseq>
        <obj>obj</obj>.frozen? 
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns the freeze status of <obj>obj</obj>.
<p/>
<codefragment>
<fullcode><![CDATA[        a = [ "a", "b", "c" ]
        a.freeze
        a.frozen?
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>a<nbsp/>=<nbsp/>[<nbsp/>"a",<nbsp/>"b",<nbsp/>"c"<nbsp/>]</tt></td>
</tr>
<tr>
  <td><tt>a.freeze</tt></td>
  <td>&#187;</td>
  <td><tt>["a",<nbsp/>"b",<nbsp/>"c"]</tt></td>
</tr>
<tr>
  <td><tt>a.frozen?</tt></td>
  <td>&#187;</td>
  <td><tt>true</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="hash" ref="hash">
      <callseq>
        <obj>obj</obj>.hash <returns><obj>aFixnum</obj></returns>
      </callseq>
      <desc>
<p/>
      Generates a <classname>Fixnum</classname> hash value for this object. This function 
      must have the property that <tt>a.eql?(b)</tt> implies <tt>a.hash == 
        b.hash</tt>. The hash value is used by class <classname>Hash</classname>.
      Any hash value that exceeds the
      capacity of a <classname>Fixnum</classname> will be truncated before being used.
<p/>
      </desc>
    </method>
<p/>
        <method name="id" ref="id">
      <callseq>
        <obj>obj</obj>.id <returns><obj>aFixnum</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns an integer identifier for <obj>obj</obj>. The same number will be 
      returned on all calls to <meth>id</meth> for a given object, and no
      two active objects will share an id. <cim><file>object</file><front>Object</front><back>id</back><mref>id</mref></cim> is a
      different concept from the <tt>:name</tt> notation, which returns the
      symbol id of <tt>name</tt>.
<p/>
      </desc>
    </method>
<p/>
        <method name="inspect" ref="inspect">
      <callseq>
        <obj>obj</obj>.inspect <returns><obj>aString</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns a string containing a human-readable representation of
      <obj>obj</obj>. If not overridden, uses the <tt>to_s</tt> method to generate
      the string.
<p/>
<codefragment>
<fullcode><![CDATA[         [ 1, 2, 3..4, 'five' ].inspect
         Time.new.inspect
]]></fullcode><rubycode>
<tr>
  <td><tt>[<nbsp/>1,<nbsp/>2,<nbsp/>3..4,<nbsp/>'five'<nbsp/>].inspect</tt></td>
  <td>&#187;</td>
  <td><tt>"[1,<nbsp/>2,<nbsp/>3..4,<nbsp/>\"five\"]"</tt></td>
</tr>
<tr>
  <td><tt>Time.new.inspect</tt></td>
  <td>&#187;</td>
  <td><tt>"Sun<nbsp/>Mar<nbsp/>04<nbsp/>23:29:19<nbsp/>CST<nbsp/>2001"</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="instance_eval" ref="instance_eval">
      <callseq>
                    <obj>obj</obj>.instance_eval(<obj>aString</obj>
                                 <opt>, <obj>file</obj>
                                         <opt><obj>line</obj></opt></opt> )
                                <returns><obj>anObject</obj></returns><br/><obj>obj</obj>.instance_eval <block>{|  | <blockbody>block</blockbody> }</block>
 <returns><obj>anObject</obj></returns>
      </callseq>
      <desc>
<p/>
      Evaluates a string containing Ruby source code, or the given
      block, within the
      context of the receiver (<obj>obj</obj>). In order to set the context, the 
      variable <var>self</var> is set to <obj>obj</obj> while the code is
      executing, giving the code access to <obj>obj</obj>'s instance variables.
      In the version of <meth>instance_eval</meth> that takes a
      <classname>String</classname>, the optional second and third parameters supply a
      filename and starting line number that are used when reporting
      compilation errors.
<p/>
<codefragment>
<fullcode><![CDATA[        class Klass
          def initialize
            @secret = 99
          end
        end
        k = Klass.new
        k.instance_eval { @secret }
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>class<nbsp/>Klass</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>def<nbsp/>initialize</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/><nbsp/><nbsp/>@secret<nbsp/>=<nbsp/>99</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>end</tt></td>
</tr>
<tr>
<td colspan="3"><tt>end</tt></td>
</tr>
<tr>
<td colspan="3"><tt>k<nbsp/>=<nbsp/>Klass.new</tt></td>
</tr>
<tr>
  <td><tt>k.instance_eval<nbsp/>{<nbsp/>@secret<nbsp/>}</tt></td>
  <td>&#187;</td>
  <td><tt>99</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="instance_of?" ref="instance_of_qm">
      <callseq>
        <obj>obj</obj>.instance_of?( <obj>aClass</obj> ) 
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if <obj>obj</obj> is an instance of the 
      given class. See also <cim><file>object</file><front>Object</front><back>kind_of?</back><mref>kind_of_qm</mref></cim>.
<p/>
      </desc>
    </method>
<p/>
        <method name="instance_variables" ref="instance_variables">
      <callseq>
        <obj>obj</obj>.instance_variables
        <returns><obj>anArray</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns an array of instance variable names for the
      receiver.
<p/>
      </desc>
    </method>
<p/>
        <method name="is_a?" ref="is_a_qm">
      <callseq>
        <obj>obj</obj>.is_a?( <obj>aClass</obj> ) 
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Synonym for <cim><file>object</file><front>Object</front><back>kind_of?</back><mref>kind_of_qm</mref></cim>.
<p/>
      </desc>
    </method>
<p/>
        <method name="kind_of?" ref="kind_of_qm">
      <callseq>
        <obj>obj</obj>.kind_of?( <obj>aClass</obj> ) 
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
              Returns <const>true</const> if <obj>aClass</obj> is the class of <obj>obj</obj>, or 
      if <obj>aClass</obj> is one of the superclasses of <obj>obj</obj> or modules included
      in <obj>obj</obj>.
<p/>
<codefragment>
<fullcode><![CDATA[        a = Integer.new
        a.instance_of? Numeric
        a.instance_of? Integer
        a.instance_of? Fixnum
        a.instance_of? Comparable
        a.kind_of? Numeric
        a.kind_of? Integer
        a.kind_of? Fixnum
        a.kind_of? Comparable
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>a<nbsp/>=<nbsp/>Integer.new</tt></td>
</tr>
<tr>
  <td><tt>a.instance_of?<nbsp/>Numeric</tt></td>
  <td>&#187;</td>
  <td><tt>false</tt></td>
</tr>
<tr>
  <td><tt>a.instance_of?<nbsp/>Integer</tt></td>
  <td>&#187;</td>
  <td><tt>true</tt></td>
</tr>
<tr>
  <td><tt>a.instance_of?<nbsp/>Fixnum</tt></td>
  <td>&#187;</td>
  <td><tt>false</tt></td>
</tr>
<tr>
  <td><tt>a.instance_of?<nbsp/>Comparable</tt></td>
  <td>&#187;</td>
  <td><tt>false</tt></td>
</tr>
<tr>
  <td><tt>a.kind_of?<nbsp/>Numeric</tt></td>
  <td>&#187;</td>
  <td><tt>true</tt></td>
</tr>
<tr>
  <td><tt>a.kind_of?<nbsp/>Integer</tt></td>
  <td>&#187;</td>
  <td><tt>true</tt></td>
</tr>
<tr>
  <td><tt>a.kind_of?<nbsp/>Fixnum</tt></td>
  <td>&#187;</td>
  <td><tt>false</tt></td>
</tr>
<tr>
  <td><tt>a.kind_of?<nbsp/>Comparable</tt></td>
  <td>&#187;</td>
  <td><tt>true</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="method" ref="method">
      <callseq>
        <obj>obj</obj>.method( <obj>aSymbol</obj> )
        <returns><obj>aMethod</obj></returns>
      </callseq>
      <desc>
<p/>
      Looks up the named method as a receiver in <obj>obj</obj>, returning a
      <classname>Method</classname> object (or raising <exception>NameError</exception>). The <classname>Method</classname> object acts
      as a closure in <obj>obj</obj>'s object instance, so instance variables
      and the value of <const>self</const> remain available.
<p/>
<codefragment>
<fullcode><![CDATA[         class Demo
           def initialize(n)
             @iv = n
           end
           def hello()
             "Hello, @iv = #{@iv}"
           end
         end
         
         k = Demo.new(99)
         m = k.method(:hello)
         m.call
         
         l = Demo.new('Fred')
         m = l.method("hello")
         m.call
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>class<nbsp/>Demo</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>def<nbsp/>initialize(n)</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/><nbsp/><nbsp/>@iv<nbsp/>=<nbsp/>n</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>end</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>def<nbsp/>hello()</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/><nbsp/><nbsp/>"Hello,<nbsp/>@iv<nbsp/>=<nbsp/>#{@iv}"</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>end</tt></td>
</tr>
<tr>
<td colspan="3"><tt>end</tt></td>
</tr>
<tr>
<td colspan="3"><tt></tt></td>
</tr>
<tr>
<td colspan="3"><tt>k<nbsp/>=<nbsp/>Demo.new(99)</tt></td>
</tr>
<tr>
<td colspan="3"><tt>m<nbsp/>=<nbsp/>k.method(:hello)</tt></td>
</tr>
<tr>
  <td><tt>m.call</tt></td>
  <td>&#187;</td>
  <td><tt>"Hello,<nbsp/>@iv<nbsp/>=<nbsp/>99"</tt></td>
</tr>
<tr>
<td colspan="3"><tt></tt></td>
</tr>
<tr>
<td colspan="3"><tt>l<nbsp/>=<nbsp/>Demo.new('Fred')</tt></td>
</tr>
<tr>
<td colspan="3"><tt>m<nbsp/>=<nbsp/>l.method("hello")</tt></td>
</tr>
<tr>
  <td><tt>m.call</tt></td>
  <td>&#187;</td>
  <td><tt>"Hello,<nbsp/>@iv<nbsp/>=<nbsp/>Fred"</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="method_missing" ref="method_missing">
      <callseq>
                <obj>obj</obj>.method_missing( <obj>aSymbol</obj> <opt>, <obj>*args</obj></opt> )
        <returns><obj>anObject</obj></returns>
      </callseq>
      <desc>
              Invoked by Ruby when <obj>obj</obj> is sent a message it cannot
      handle. <obj>aSymbol</obj> is the symbol for the method called,
      and <obj>args</obj> are any arguments that were passed to it. The
      example below creates a class <tt>Roman</tt>, which responds to methods
      with names consisting of roman numerals, returning the corresponding
      integer values.
<p/>
<codefragment>
<alltt><fullcode><![CDATA[        class Roman
          def romanToInt(str)
            # ...
!-            case str
!-            when "iv"; return 4
!-            when "xxiii"; return 23
!-            when "mm"; return 2000
!-            else; raise "oops #{str}"
!-            end
          end         
          def method_missing(methId)
            str = methId.id2name
            romanToInt(str)
          end
        end
]]></fullcode>
class<nbsp/>Roman
<nbsp/><nbsp/>def<nbsp/>romanToInt(str)
<nbsp/><nbsp/><nbsp/><nbsp/>#<nbsp/>...
<nbsp/><nbsp/>end
<nbsp/><nbsp/>def<nbsp/>method_missing(methId)
<nbsp/><nbsp/><nbsp/><nbsp/>str<nbsp/>=<nbsp/>methId.id2name
<nbsp/><nbsp/><nbsp/><nbsp/>romanToInt(str)
<nbsp/><nbsp/>end
end
</alltt>
</codefragment>
<p/>
<codefragment>
<fullcode><![CDATA[!-        class Roman
!-          def romanToInt(str)
!-            # ...
!-            case str
!-            when "iv"; return 4
!-            when "xxiii"; return 23
!-            when "mm"; return 2000
!-            else; raise "oops #{str}"
!-            end
!-          end         
!-          def method_missing(methId)
!-            str = methId.id2name
!-            romanToInt(str)
!-          end
!-        end
        r = Roman.new
        r.iv
        r.xxiii
        r.mm
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>r<nbsp/>=<nbsp/>Roman.new</tt></td>
</tr>
<tr>
  <td><tt>r.iv</tt></td>
  <td>&#187;</td>
  <td><tt>4</tt></td>
</tr>
<tr>
  <td><tt>r.xxiii</tt></td>
  <td>&#187;</td>
  <td><tt>23</tt></td>
</tr>
<tr>
  <td><tt>r.mm</tt></td>
  <td>&#187;</td>
  <td><tt>2000</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="methods" ref="methods">
      <callseq>
        <obj>obj</obj>.methods <returns><obj>anArray</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns a list of the names of methods publicly accessible in
      <obj>obj</obj>. This will include all the methods accessible in <obj>obj</obj>'s
      ancestors. 
<p/>
<codefragment>
<fullcode><![CDATA[         class Klass
           def kMethod()
           end
         end
         k = Klass.new
         k.methods[0..9]
         k.methods.length
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>class<nbsp/>Klass</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>def<nbsp/>kMethod()</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>end</tt></td>
</tr>
<tr>
<td colspan="3"><tt>end</tt></td>
</tr>
<tr>
<td colspan="3"><tt>k<nbsp/>=<nbsp/>Klass.new</tt></td>
</tr>
<tr>
  <td><tt>k.methods[0..9]</tt></td>
  <td>&#187;</td>
  <td><tt>["kMethod",<nbsp/>"instance_of?",<nbsp/>"protected_methods",<nbsp/>"inspect",<nbsp/>"freeze",<nbsp/>"dup",<nbsp/>"__id__",<nbsp/>"equal?",<nbsp/>"send",<nbsp/>"=="]</tt></td>
</tr>
<tr>
  <td><tt>k.methods.length</tt></td>
  <td>&#187;</td>
  <td><tt>38</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="nil?" ref="nil_qm">
      <callseq>
        <obj>obj</obj>.nil? <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      All objects except <tt>nil</tt> return <const>false</const>.
<p/>
      </desc>
    </method>
<p/>
        <method name="private_methods" ref="private_methods">
      <callseq>
        <obj>obj</obj>.private_methods
        <returns><obj>anArray</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns a list of private methods accessible within <obj>obj</obj>. This
      will include the private methods in <obj>obj</obj>'s ancestors, along
      with any mixed-in module functions.
<p/>
      </desc>
    </method>
<p/>
        <method name="protected_methods" ref="protected_methods">
      <callseq>
        <obj>obj</obj>.protected_methods
        <returns><obj>anArray</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns the list of protected methods accessible to <obj>obj</obj>.
<p/>
      </desc>
    </method>
<p/>
        <method name="public_methods" ref="public_methods">
      <callseq>
                <obj>obj</obj>.public_methods <returns><obj>anArray</obj></returns>
      </callseq>
      <desc>
<p/>
      Synonym for <cim><file>object</file><front>Object</front><back>methods</back><mref>methods</mref></cim>.
<p/>
      </desc>
    </method>
<p/>
        <method name="respond_to?" ref="respond_to_qm">
      <callseq>
                <obj>obj</obj>.respond_to?( <obj>aSymbol</obj>,
                            <obj>includePriv</obj>=<const>false</const> )
            <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if <obj>obj</obj> responds to the given
      method. Private methods are included in the search only if the
      optional second parameter evaluates to <const>true</const>.
<p/>
      </desc>
    </method>
<p/>
        <method name="send" ref="send">
      <callseq>
        <obj>obj</obj>.send( <obj>aSymbol</obj>
        <optz>, <obj>args</obj></optz> ) <returns><obj>anObject</obj></returns>
      </callseq>
      <desc>
<p/>
      Invokes the method identified by <obj>aSymbol</obj>, passing it any
      arguments specified. You can use <meth>__send__</meth> if the
      name <meth>send</meth> clashes with an existing method in <obj>obj</obj>.
<p/>
<codefragment>
<fullcode><![CDATA[        class Klass
          def hello(*args)
            "Hello " + args.join(' ')
          end
        end
        k = Klass.new
        k.send :hello, "gentle", "readers"
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>class<nbsp/>Klass</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>def<nbsp/>hello(*args)</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/><nbsp/><nbsp/>"Hello<nbsp/>"<nbsp/>+<nbsp/>args.join('<nbsp/>')</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>end</tt></td>
</tr>
<tr>
<td colspan="3"><tt>end</tt></td>
</tr>
<tr>
<td colspan="3"><tt>k<nbsp/>=<nbsp/>Klass.new</tt></td>
</tr>
<tr>
  <td><tt>k.send<nbsp/>:hello,<nbsp/>"gentle",<nbsp/>"readers"</tt></td>
  <td>&#187;</td>
  <td><tt>"Hello<nbsp/>gentle<nbsp/>readers"</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="singleton_methods" ref="singleton_methods">
      <callseq>
        <obj>obj</obj>.singleton_methods
        <returns><obj>anArray</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns an array of the names of singleton methods for <obj>obj</obj>.
<p/>
<codefragment>
<fullcode><![CDATA[          class Klass
            def Klass.classMethod
            end
          end
          k = Klass.new
          def k.sm()
          end
          Klass.singleton_methods
          k.singleton_methods
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>class<nbsp/>Klass</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>def<nbsp/>Klass.classMethod</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>end</tt></td>
</tr>
<tr>
<td colspan="3"><tt>end</tt></td>
</tr>
<tr>
<td colspan="3"><tt>k<nbsp/>=<nbsp/>Klass.new</tt></td>
</tr>
<tr>
<td colspan="3"><tt>def<nbsp/>k.sm()</tt></td>
</tr>
<tr>
<td colspan="3"><tt>end</tt></td>
</tr>
<tr>
  <td><tt>Klass.singleton_methods</tt></td>
  <td>&#187;</td>
  <td><tt>["classMethod"]</tt></td>
</tr>
<tr>
  <td><tt>k.singleton_methods</tt></td>
  <td>&#187;</td>
  <td><tt>["sm"]</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="taint" ref="taint">
      <callseq>
        <obj>obj</obj>.taint <returns><obj>obj</obj></returns>
      </callseq>
      <desc>
<p/>
      Marks <obj>obj</obj> as tainted      
      (see Chapter 20, which begins on page 257).
<p/>
      </desc>
    </method>
<p/>
        <method name="tainted?" ref="tainted_qm">
      <callseq>
        <obj>obj</obj>.tainted? <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if the object is tainted.
<p/>
      </desc>
    </method>
<p/>
        <method name="to_a" ref="to_a">
      <callseq>
        <obj>obj</obj>.to_a <returns><obj>anArray</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns an array representation of <obj>obj</obj>. For
      objects of class <classname>Object</classname> and others that don't explicitly
      override the method, the return value is an array containing <const>self</const>.
<p/>
<codefragment>
<fullcode><![CDATA[         self.to_a
         "hello".to_a
         Time.new.to_a
]]></fullcode><rubycode>
<tr>
  <td><tt>self.to_a</tt></td>
  <td>&#187;</td>
  <td><tt>[main]</tt></td>
</tr>
<tr>
  <td><tt>"hello".to_a</tt></td>
  <td>&#187;</td>
  <td><tt>["hello"]</tt></td>
</tr>
<tr>
  <td><tt>Time.new.to_a</tt></td>
  <td>&#187;</td>
  <td><tt>[19,<nbsp/>29,<nbsp/>23,<nbsp/>4,<nbsp/>3,<nbsp/>2001,<nbsp/>0,<nbsp/>63,<nbsp/>false,<nbsp/>"CST"]</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="to_s" ref="to_s">
      <callseq>
        <obj>obj</obj>.to_s <returns><obj>aString</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns a string representing <obj>obj</obj>. The default <meth>to_s</meth>
      prints the object's class and an encoding of the object id. As a
      special case, the top-level object that is the initial execution 
      context of Ruby programs returns ``main.''
<p/>
      </desc>
    </method>
<p/>
        <method name="type" ref="type">
      <callseq>
        <obj>obj</obj>.type <returns><obj>aClass</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns the class of <obj>obj</obj>. 
<p/>
      </desc>
    </method>
<p/>
        <method name="untaint" ref="untaint">
      <callseq>
        <obj>obj</obj>.untaint <returns><obj>obj</obj></returns>
      </callseq>
      <desc>
<p/>
      Removes the taint from <obj>obj</obj>.
<p/>
      </desc>
    </method>
<p/>
  </methods>
<p/>
</class>
</ppdoc>