Merge pull request #428 from davefp/ruby_attr_accessor

[ruby/en] Adds attr_accessor, attr_reader, and attr_writer to class docs
This commit is contained in:
Nami-Doc 2013-12-02 04:25:45 -08:00
commit 53272e5f11

View File

@ -323,6 +323,13 @@ class Human
@name
end
# The above functionality can be encapsulated using the attr_accessor method as follows
attr_accessor :name
# Getter/setter methods can also be created individually like this
attr_reader :name
attr_writer :name
# A class method uses self to distinguish from instance methods.
# It can only be called on the class, not an instance.
def self.say(msg)