You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
829 B
31 lines
829 B
require_relative 'person'
|
|
|
|
class StudentShort < Person
|
|
attr_reader :surname_initials, :contact
|
|
|
|
def initialize(student)
|
|
super(id: student.id, git: student.git_info)
|
|
@surname_initials = student.surname_and_initials
|
|
@contact = student.contact_info
|
|
end
|
|
|
|
def self.from_string(id, info_string)
|
|
parts = info_string.split(', ').map(&:strip)
|
|
surname_initials = parts[0]
|
|
git = parts[1].split(': ').last
|
|
contact = parts[2].split(': ').last
|
|
|
|
new_instance = allocate
|
|
new_instance.send(:initialize_from_data, id, surname_initials, git, contact)
|
|
new_instance
|
|
end
|
|
|
|
private
|
|
|
|
def initialize_from_data(id, surname_initials, git, contact)
|
|
@id = id
|
|
@surname_initials = surname_initials
|
|
@git = git
|
|
@contact = contact
|
|
end
|
|
end |