Home
Ruby
ActiveRecord
Array
CGI
Class
Collections
Database
Date
Design Patterns
Development
File Directory
GUI
Hash
Language Basics
Method
Network
Number
Rails
Range
Reflection
Statement
String
Threads
Time
Tk
Unit Test
Windows Platform
XML
attr_reader « Class « Ruby
Ruby
Class
attr_reader
1.
attr_reader creates one or more instance variables, with corresponding methods that return (get) the values of each method.
2.
Calling the attr_accessor method does the same job as calling both attr_reader and attr_writer together, for one or more instance methods
3.
Use attr_reader to add a new attribute and use initialize method to set it
4.
attr_reader creates these accessor methods for you.