|
|
@ -41,6 +41,26 @@ class Student < Person
|
|
|
|
git: git
|
|
|
|
git: git
|
|
|
|
)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def self.read_from_txt(file_path)
|
|
|
|
|
|
|
|
raise IOError, "File path is invalid or file does not exist: #{file_path}" unless File.exist?(file_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
students = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
File.foreach(file_path) do |line|
|
|
|
|
|
|
|
|
line.strip!
|
|
|
|
|
|
|
|
next if line.empty? # Пропустить пустые строки
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
|
|
|
student = from_string(line)
|
|
|
|
|
|
|
|
students << student
|
|
|
|
|
|
|
|
rescue ArgumentError => e
|
|
|
|
|
|
|
|
puts "Error processing line: '#{line}'. Reason: #{e.message}"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
students
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def surname_and_initials
|
|
|
|
def surname_and_initials
|
|
|
|
"#{@surname} #{name[0]}.#{patronymic[0]}."
|
|
|
|
"#{@surname} #{name[0]}.#{patronymic[0]}."
|
|
|
|