Skip to content

Instantly share code, notes, and snippets.

@TrevMcKendrick
Last active December 25, 2015 00:49
Show Gist options
  • Save TrevMcKendrick/6890396 to your computer and use it in GitHub Desktop.
Save TrevMcKendrick/6890396 to your computer and use it in GitHub Desktop.
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