Mega Code Archive
Search
.Net
ASP .Net
ASP .Net Tutorial
C#
C# Book
C# by API
C# Tutorial
VB.Net
VB.Net by API
VB.Net Tutorial
Visual C++ .Net
VisualBasic Script
Java
Java
Java Book
Java by API
Java Tutorial
Script
Flash ActionScript
Flex
JavaScript DHTML
JavaScript Reference
JavaScript Tutorial
Database
MSSQL
MSSQL Tutorial
MySQL
MySQL Tutorial
Oracle PLSQL
Oracle PLSQL Tutorial
PostgreSQL
Languages
Android
C
C Tutorial
C++
C++ Tutorial
Delphi
Perl
PHP
Python
Python Tutorial
Ruby
Silverlight
Office
MSOfficeExcel 2007 Tutorial
MSOfficePowerPoint 2007 Tutorial
MSOfficeWord 2007 Tutorial
Data
XML
XML Tutorial
Ruby
Class 146 codes
Home
Ruby
Class
1 == and equal are different
2 A class is defined with the class keyword, followed by an end
3 A class is itself an object
4 A class member marked public is accessible by anyone from anywhere; it is the default
5 A class with public, protected and private accessors
6 A logger
7 A method marked protected can be used only by instances of the class where it was defined, or by derived classes
8 A simple class thats been documented using comments
9 A simple demonstration of a class with two methods
10 Abs absolute value method
11 Access inner classes
12 Accessors
13 Add a method named get_color, which returns the color of animal objects created from this class
14 Add a singleton method to a instance object
15 Add extension from a module for an object not class
16 Add method implementation for object instance
17 Add method to a variable only
18 Add method to child class
19 Add method to class to create abstract method dynamically
20 Add methods in subclass
21 Add more accessors in child class
22 Add new constructor
23 Add private method to Object and call it in instance class
24 Add singleton method to a string instance
25 Adding more accessors
26 Alias method name
27 All strings in Ruby are objects of the String class, as you can discover by calling a strings class method
28 As an interface
29 Attr_accessor add accessor to a class
30 Attr_reader creates one or more instance variables, with corresponding methods that return (get) the values of each method
31 Attr_reader creates these accessor methods for you
32 Basing One Class on Another
33 Basing one class on another is called inheritance
34 Call a member method
35 Call constructor from parent class
36 Calling the attr_accessor method does the same job as calling both attr_reader and attr_writer together, for one or more instance me
37 Check class attribute of child class
38 Check if an object is considered tainted by using the tainted method
39 Check new added instance methods against Object
40 Class methods give you the mechanism to properly implement the object counter
41 Class template
42 Class to string
43 Class variable and instance variable with the same name
44 Class variable as condition variable
45 Class variable vs object variable
46 Class with symboles
47 Clone a customized string
48 Compare method
49 Controlling Access by Making Methods Private
50 Create a class dynamically
51 Create HexNumber
52 Creating an Abstract Class and Method
53 Creating an Object
54 Creating Class Methods
55 Creating Class Variables
56 Creating Objects by Passing Parameters to the New Method
57 Creating Objects the Simple Way
58 Creating Readable and Writable Attributes
59 Creating Readable Attributes
60 Creating Writable Attributes
61 Define a method to retrieve the value
62 Define constructor for a class
63 Define getter for a attribute
64 Define operator for class
65 Define plus operator
66 Defining and Using an Employee Class
67 Defining Methods within a Class
68 Delegating Method Calls to Another Object
69 Different types of people
70 Encapsulation Demo
71 Eql and == are different
72 Everything is an object or object-oriented in Ruby
73 Extending Specific Objects with Modules
74 Extends a frozen class
75 Extends class
76 Force an object to be seen as untainted by calling the untaint method on the object
77 Format ourselves as a string by appending our lyrics to our parents #to_s value
78 Freeze a class
79 Get new defined instance methods
80 Get the modules Object class belongs to
81 Getter and setter
82 Getting a Human-Readable Printout of Any Object
83 How inheritance works in code form
84 If the class Name were in a different file, you would just require that file first
85 Implement an each method, and get these methods for free
86 In Ruby, you prefix instance variables with an at sign @
87 Include a module into a class
88 Include module with same method name
89 Include two modules
90 Initialize three attributes
91 Initializes the instance variable @name with the standard initialize method
92 Label methods
93 Make an attribute readable and writable by using attr_reader, attr_writer
94 Making a Copy of an Object
95 Module and class hierarchy
96 Names of classes in Ruby start with a capital letter
97 OpenStruct class provided by the ostruct library makes it even easier
98 Override a to_s method after inheritance
99 Override method from parent
100 Override the inspect the method to provide a better print out
101 Override your own methods
102 Overriding Existing Methods
103 Overriding Methods Demo
104 Place classes within other classes These are called nested classes
105 Polymorphism Demo
106 Print out a class
107 Print out the instance variable
108 Protected that makes a method private, but within the scope of a class rather than within a single object
109 Provide the getter
110 Public is default
111 Readable attribute and writable attribute
112 Ruby gives you a quick way to create writable attributes with attr_writer
113 Ruby gives you three levels of access
114 Ruby makes creating readable attribute easier with attr_reader
115 Ruby terms multiple inheritance a mixin
116 Same value but different reference
117 Self represents the current class
118 Setter with =
119 Setter with calculation
120 Singleton method not copied
121 Static class method
122 Struct creates small data-handling classes on the fly
123 Structuring Your Pets Logically
124 Subclass Array class
125 Tell if a certain operation is safe
126 The area method is made available in all objects of class Square
127 The code adds an instance variable named @color that stores the color of the animal to the initialize method
128 The style ClassName method_name versus self method_name to define class method
129 This code starts by creating the Animal class, and then adds a method named initialize
130 To create a class in Ruby, you simply use the class statement
131 To embed a module in a class, you use the include statement in the class
132 To pass the color to the constructor of the base class, you use the special super method
133 Update both instance variable and class variable
134 Use === to compare values
135 Use attr to add two attributes
136 Use attr_accessor to add a new attribute and set it
137 Use attr_reader to add a new attribute and use initialize method to set it
138 Use equal to check the references
139 Use extend to include a module to create single methods
140 Using a Constructor to Configure Objects
141 Using attr_writer
142 Virtual method Demo
143 When you make a method private, its not accessible outside the object its defined in
144 When you use an access modifier, all the methods that follow are defined with that access, until you use a different access modifier
145 Your class with constructor, to string, setter, getter and inspect
146 Your own class with inspect method