|
|
|
@ -8,10 +8,10 @@ class Student < Person
|
|
|
|
|
|
|
|
|
|
def initialize(id:, git:, contact:, surname:, name:, patronymic:, birth_date:)
|
|
|
|
|
super(id: id, git: git, contact: contact)
|
|
|
|
|
@surname = surname
|
|
|
|
|
@name = name
|
|
|
|
|
@patronymic = patronymic
|
|
|
|
|
@birth_date = birth_date
|
|
|
|
|
self.surname = surname
|
|
|
|
|
self.name = name
|
|
|
|
|
self.patronymic = patronymic
|
|
|
|
|
self.birth_date = birth_date
|
|
|
|
|
|
|
|
|
|
validate_student
|
|
|
|
|
end
|
|
|
|
@ -58,6 +58,34 @@ class Student < Person
|
|
|
|
|
"#{surname_and_initials}, Git: #{@git}, Contact: #{contact_info}, Birth Date: #{@birth_date}"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def surname=(surname)
|
|
|
|
|
raise ArgumentError, 'Surname is required' if surname.nil? || surname.strip.empty?
|
|
|
|
|
raise ArgumentError, "Invalid surname format: #{surname}" unless valid_name?(surname)
|
|
|
|
|
|
|
|
|
|
@surname = surname
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def name=(name)
|
|
|
|
|
raise ArgumentError, 'Name is required' if name.nil? || name.strip.empty?
|
|
|
|
|
raise ArgumentError, "Invalid name format: #{name}" unless valid_name?(name)
|
|
|
|
|
|
|
|
|
|
@name = name
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def patronymic=(patronymic)
|
|
|
|
|
raise ArgumentError, 'Patronymic is required' if patronymic.nil? || patronymic.strip.empty?
|
|
|
|
|
raise ArgumentError, "Invalid patronymic format: #{patronymic}" unless valid_name?(patronymic)
|
|
|
|
|
|
|
|
|
|
@patronymic = patronymic
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def birth_date=(birth_date)
|
|
|
|
|
raise ArgumentError, 'Birth date is required' if birth_date.nil?
|
|
|
|
|
raise ArgumentError, "Invalid birth date: #{birth_date}" unless birth_date.is_a?(Date)
|
|
|
|
|
|
|
|
|
|
@birth_date = birth_date
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def validate_student
|
|
|
|
|