On 2012-09-01, at 8:54 AM, Rubyist R. [email protected] wrote:
This is quite confusing in Ruby as method and properties look alike.
You’ve got a terminology thing going on and this is confusing you I
think. There are no such thing as ‘properties’ in Ruby (google it and
you can read about the magical healing properties of the ruby gemstone
Generally speaking you’ve got attributes and methods. There are two
kinds of attributes (class and instance) but you’re talking about
instance attributes. Attributes are private to an object, only the
specific instance has access to them. They are idiomatically and
optionally exposed to other objects through ‘accessor methods’ which are
just methods with a naming convention, nothing at all special about
them. Ruby provides three ways to concisely ask Ruby to generate
accessor methods for you: attr_reader, attr_writer, attr_accessor.
Idiomatic Ruby is to use these automated accessors. However, it’s
possible that you have something more complex you have to do in which
case you’d write your own accessors.
To correct my original post, shall I remove ‘attr_accessor’ to make
Since you are not doing anything special, use idiomatic Ruby:
======== [CODE] =======