An attr_reader is getter specially designed to replace the typical method for returning an attribute’s value.
An attr_writer is a setter specially designed to replace a method for setting an attribute’s value.
@job = newJob
With the getter, we simply write,
john = Person.new('John', 'programmer')
puts john.name # John
john.job = 'analyst'
One assumes we will have an attr_reader for
job as well,
attr_reader :name, :job
puts john.job # analyst
There is one more detail relating to both read and write,
This will install both a getter and a setter on the
job attribute so we don’t need to give it a reader or a writer.
Relating to the colon, it is part of the identifier and in Ruby it is known as a symbol.