Skip to content

Commit 0bc94f2

Browse files
committed
Working on "Objects and Class", not finished
1 parent b890b2b commit 0bc94f2

6 files changed

+50
-0
lines changed

img/fixnum_object.png

30.6 KB
Loading

img/generic_iv_tbl.png

23.1 KB
Loading

img/generic_objects.png

34.1 KB
Loading

img/r_object.png

15.9 KB
Loading

img/r_object_example.png

30 KB
Loading

index.html

+50
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,56 @@ <h3>Catch table</h3>
10031003
<img src="img/catch_table.png" />
10041004
</section>
10051005
</section>
1006+
<section>
1007+
<section>
1008+
<h1>Objects &amp; Class</h1>
1009+
</section>
1010+
<section>
1011+
<h3>RObject</h3>
1012+
<img src="img/r_object.png" />
1013+
<aside class="notes">
1014+
<p>At the top of the figure is a pointer to the RObject structure. (Internally, Ruby always refers to any value with a VALUE pointer.) Below this pointer, the RObject structure contains an inner RBasic structure and information spe- cific to custom objects. The RBasic sec- tion contains information that all values use: a set of Boolean values called flags that store a variety of internal technical values, and a class pointer called klass.</p>
1015+
<p>The class pointer indicates which class an object is an instance of. In the RObject section, Ruby saves an array of instance variables that each object contains, using numiv, the instance variable count, and ivptr, a pointer to an array of values.</p>
1016+
</aside>
1017+
</section>
1018+
<section>
1019+
<h3>Example</h3>
1020+
<pre><code>
1021+
class Mathematician
1022+
attr_accessor :first_name
1023+
attr_accessor :last_name
1024+
end
1025+
1026+
euler = Mathematician.new
1027+
euler.first_name = 'Leonhard'
1028+
euler.last_name = 'Euler'
1029+
1030+
euclid = Mathematician.new
1031+
euclid.first_name = 'Euclid'
1032+
</code></pre>
1033+
</section>
1034+
<section>
1035+
<img src="img/r_object_example.png" />
1036+
</section>
1037+
<section>
1038+
<h3>Generic Objects</h3>
1039+
<img src="img/generic_objects.png" />
1040+
</section>
1041+
<section>
1042+
<h3>Fixnum</h3>
1043+
<img src="img/fixnum_object.png" />
1044+
<aside class="notes">
1045+
Symbol, NilClass, TrueClass, FalseClass has their owned flags.
1046+
</aside>
1047+
</section>
1048+
<section>
1049+
<h3>How do generic objects have instance variables?</h3>
1050+
<img src="img/generic_iv_tbl.png" />
1051+
<aside class="notes">
1052+
All generic objects don't have their owned numiv and ivptr.
1053+
</aside>
1054+
</section>
1055+
</section>
10061056
</div>
10071057
</div>
10081058

0 commit comments

Comments
 (0)