title: Ruby - How to set value for dynamic attribute in class
body: <p>I have a class like this</p>
  
  <pre><code>class A
      #this array of attributes is dynamic, just give example for understanding easier
      attributes = ['abc','S1','S2','S3']
      attributes.each do |e|
          attr_accessor e.to_sym
      end
  end
  </code></pre>
  
  <p>I want to call setter for each attribute. So, I tried this (for you understand what I want)</p>
  
  <pre><code>a = A.new
  attributes = ['abc','S1','S2','S3']
  attributes.each do |attr|
      #I know the following command is wrong (because 'attr' is not a attribute of class A)
      a.attr = 1
  end
  </code></pre>
  
  <p>So, how to call setter for dynamic attribute? </p>
  
  <p>P/s: using Ruby 1.8.7 and Rails 2.3.5 
  Thank you.</p>