summaryrefslogtreecommitdiffhomepage
path: root/ruby.html.markdown
diff options
context:
space:
mode:
authorDavid Underwood <davefp@gmail.com>2013-12-01 21:42:51 -0500
committerDavid Underwood <davefp@gmail.com>2013-12-01 21:43:48 -0500
commit02044c1eab7d7d8a670c1f63b004e91df83d22c4 (patch)
tree2f99b4c23bd408004f6e4cb4e054f7166c103c4f /ruby.html.markdown
parenta36cee194b40dd59608d3e306e74e1b68ba9aa46 (diff)
Ruby: Adds attr_accessor, attr_reader, and attr_writer to class docs
Diffstat (limited to 'ruby.html.markdown')
-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)