summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNami-Doc <vendethiel@hotmail.fr>2013-12-02 04:25:45 -0800
committerNami-Doc <vendethiel@hotmail.fr>2013-12-02 04:25:45 -0800
commit53272e5f112aab68458e2faab153b3c61ada8cf0 (patch)
tree4c328c34988dc2bc6eec1eae0f073e7927899463
parent3e1e00b8f862735cd82e0deccfe4db8957b77df0 (diff)
parent02044c1eab7d7d8a670c1f63b004e91df83d22c4 (diff)
Merge pull request #428 from davefp/ruby_attr_accessor
[ruby/en] Adds attr_accessor, attr_reader, and attr_writer to class docs
-rw-r--r--ruby.html.markdown7
1 files changed, 7 insertions, 0 deletions
diff --git a/ruby.html.markdown b/ruby.html.markdown
index bf4cb229..a4c74a4f 100644
--- a/ruby.html.markdown
+++ b/ruby.html.markdown
@@ -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)