Check out example codes for "attr_accessor ruby". It will help you in understanding the concepts better.

Code Example 1

class Food
 attr_accessor :protein
 def initialize(protein)
   @protein = protein
 end
end

Code Example 2

class Person
  attr_reader :name, :age, :sex, :email
  attr_writer :name, :age, :sex, :email

  def initialize(name)
    @name = name
  end
end

Learn ReactJs, React Native from akashmittal.com