Created
October 11, 2013 15:55
-
-
Save TrevMcKendrick/6937224 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Student | |
attr_accessor :name, :twitter, :linkedin, :facebook, :website | |
attr_reader :id | |
@@students = [] | |
def initialize | |
@@students << self | |
@id = @@students.count | |
end | |
def self.all | |
@@students | |
end | |
def self.reset_all | |
@@students.clear | |
end | |
def self.find_by_name(student_name) | |
@@students.select do |person| | |
person if person.name == student_name | |
end | |
end | |
def self.find(id) | |
@@students[id-1] | |
end | |
def self.delete(id) | |
@@students.delete_at(id-1) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment