Ruby Types
¶ ↑
Ruby Types introduces group of classes as eqivalent to some data types in other languages such as boolean
and allows introspection according to type of class too. In fact, partially replaces multiple inheritance because introduces unlimited formal genericity for every class.
For example define:
class Boolean < Type def type_classes [TrueClass, FalseClass] end end
Then you can call:
foo = 5 bar = true foo.type_of? Boolean # returns false bar.type_of? Boolean # returns true
Binding back to classic behaviour works:
foo.type_of? Numeric # returns true
By overriding #type_types
method of the Type
class you can achieve also types inheritance by the same way as mentioned above.
Contributing¶ ↑
-
Fork it.
-
Create a branch (
git checkout -b 20101220-my-change
). -
Commit your changes (
git commit -am "Added something"
). -
Push to the branch (
git push origin 20101220-my-change
). -
Create an Issue with a link to your branch.
-
Enjoy a refreshing Diet Coke and wait.
Copyright¶ ↑
Copyright © 2011 Martin Kozák. See LICENSE.txt
for further details.