title: How do I create instances of a Ruby class from data in an array?
body: <p>I've got an array of strings. Example:</p>
  
  <pre><code>array = [ "mmaciel:x:23585:591:mmaciel:/students/mmaciel:/bin/bash\n", 
            "nhalvors:x:20943:565:nhalvors:/students/nhalvors:/bin/bash\n", 
            "orodrigu:x:28260:576:orodrigu:/students/orodrigu:/bin/bash\n" ]
  </code></pre>
  
  <p>And I want to populate class Student:</p>
  
  <pre><code>class Student
    attr_accessor :user_name, :password, :uid, :gid,
                  :gcos_field, :directory, :shell
    attr_reader :count
  
    def initialize(data)
      @user_name,@password,@uid,@gid,@gcos_field,@directory,@shell = data
      @@count = defined?(@@count) ? @@count += 1 : 1
  
    end
  end
  </code></pre>
  
  <p>If it's just one element of the array, it's simple to me. Simply:</p>
  
  <pre><code>data = "dputnam:x:4185:208:Douglas Vernon Putnam:/users/dputnam:/bin/bash".split(':')
  s1 = Student.new(data)
  </code></pre>
  
  <p>But since I have an array of dozens of elements, it becomes much more complicated for me. Any help would be appreciated.</p>