Attr Macros let you define Getter and/or Setter for a specified variable.
There are three different types of attr macros:
Class YourClass
# it creates a getter method for each of the vars specified
attr_reader :var1, :var2, :var3
# now it create a setter method
attr_writer :var1, :var2, :var3
# now it creates both getter and setter
attr_accessor :var4
end
—-
If you need to assign a initial value to your variable you can use attr_with_value
Attr Macros let you define Getter and/or Setter for a specified variable.
There are three different types of attr macros:
Class YourClass
# it creates a getter method for each of the vars specified
attr_reader :var1, :var2, :var3
# now it create a setter method
attr_writer :var1, :var2, :var3
# now it creates both getter and setter
attr_accessor :var4
end
—-
If you need to assign a initial value to your variable you can use attr_with_value