Last active
December 25, 2015 00:49
-
-
Save TrevMcKendrick/6890396 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 | |
students = [{:name => "Trevor"}] | |
students.each do |student_hash| | |
s = Student.new | |
s.name = student_hash[:name] | |
end | |
Student.all | |
CLIStudent.new | |
CLIStudent.call |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment