require_relative 'contact' require_relative 'person' require_relative 'student' require_relative 'student_short' require_relative 'student_repository' def test_classes contact = Contact.new(phone: '+798912465', telegram: '@example_user', email: 'test@example.com') puts "Contact Info: #{contact.info}" person = Person.new(id: '1', git: 'https://github.com/example', contact: contact) puts "Person Contact Info: #{person.contact_info}" student = Student.new( id: '2', git: 'https://github.com/student_example', contact: contact, surname: 'Иванов', name: 'Иван', patronymic: 'Иванович' ) puts "Student Full Info: #{student.to_s}" puts "Student Initials: #{student.surname_and_initials}" puts "Student Contact Info: #{student.contact_info}" student_short = StudentShort.from_student(student) puts "Student Short Info: #{student_short.to_s}" file_path = 'students.txt' students = StudentRepository.read_from_txt(file_path) puts "Read Students from File:" students.each { |s| puts s.to_s } output_path = 'output_students.txt' StudentRepository.write_to_txt(output_path, students) puts "Students written to file: #{output_path}" end def test_parsing student_string = 'Иванов Иван Иванович | ID: 3 | Phone: +79876543210 | Telegram: @ivan_user | Email: ivan@example.com | Git: https://github.com/ivanov' student = Student.from_string(student_string) puts "Parsed Student: #{student.to_s}" short_string = 'Иванов И.И., Git: https://github.com/ivanov, Contact: Phone: +79876543210' student_short = StudentShort.from_string('4', short_string) puts "Parsed StudentShort: #{student_short.to_s}" end if __FILE__ == $0 puts "=== Testing Classes ===" test_classes puts "\n=== Testing Parsing ===" test_parsing end