Braindump / Ch 2 Beginning Ruby
June 20, 2008 @ 11:55 PM | posted by carmelyne
(last updated: 06.21.08)CH 2: TOUR OF RUBY & OBJECT ORIENTATION
Object
- an object is a single instance of a class.
- object is the actual object or “thing” itself.
- an object of class Person is a single person
Classes
- a class is the classification
- the definition of a single type of object
- starts with a capital letter just like global constants which therefore makes it available as a global constant.
attr in attr_accessor
- stands for “attribute”
accessor in attr_accessor
- roughly means “make these attributes accessible to be set and changed.”
Inheritance like Single Table Inheritance
- hierarchy of classes; and sub/child classes inherits attributes and methods from the parent class
- can still add class-specific code to sub/child class
Class Method
- ruby supplies all objects a class by default
- you can ask any object of which class it’s a member by using its class method, i.e. puts 2.class
Fixnum Class
- numbers
Kernel & Kernel Methods
- kernel is a special class(actually, a module) whose methods are made available in every class and scope throughout ruby.
puts
- is a method made available from the Kernel module
Kernel module
- a special type of class packed full of standard, commonly used methods, making your code easier to read and write
String Class
- strings
- has many methods, examples: capitalize, downcase, chop, hash, next, reverse, sum, or swapcase.
Braindumps from Beginning Ruby
[ Last updated: June 21, 2008 @ 12:34 AM ]




Sorry, comments are closed for this article.