From 2126888d8a51c682d4948589915bdfdd9f314161 Mon Sep 17 00:00:00 2001 From: Artem Darius Weber Date: Mon, 6 Jan 2025 13:15:58 +0300 Subject: [PATCH] refactor: implement surname_initials method and update references for consistency --- lab2/README.md | 1 + lab2/main.rb | 2 +- lab2/person.rb | 4 ++++ lab2/student_short.rb | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lab2/README.md b/lab2/README.md index 5595ad1..7a14f08 100644 --- a/lab2/README.md +++ b/lab2/README.md @@ -30,6 +30,7 @@ classDiagram + phone=(String) : Boolean + telegram=(String) : Boolean + email=(String) : Boolean + + surname_initials() : NotImplementedError + valid_phone_number() : Boolean <> + valid_telegram() : Boolean <> + valid_email() : Boolean <> diff --git a/lab2/main.rb b/lab2/main.rb index f7b3fde..1fa3b48 100644 --- a/lab2/main.rb +++ b/lab2/main.rb @@ -21,7 +21,7 @@ def test_classes email: 'ivanov@example.com' ) puts "Student Full Info: #{student.to_s}" - puts "Student Initials: #{student.surname_and_initials}" + puts "Student Initials: #{student.surname_initials}" puts "Student Contact Info: #{student.get_first_contact}" student_short = StudentShort.from_student(student) diff --git a/lab2/person.rb b/lab2/person.rb index d31be6c..e01ab4e 100644 --- a/lab2/person.rb +++ b/lab2/person.rb @@ -12,6 +12,10 @@ class Person @git = git end + def surname_initials + raise NotImplementedError, "#{self.class} must implement the 'surname_initials' method" + end + def git_present? !@git.nil? && !@git.empty? end diff --git a/lab2/student_short.rb b/lab2/student_short.rb index 80bc23a..0d5ebbe 100644 --- a/lab2/student_short.rb +++ b/lab2/student_short.rb @@ -12,7 +12,7 @@ class StudentShort < Person def self.from_student(student) new( id: student.id, - surname_initials: student.surname_and_initials, + surname_initials: student.surname_initials, phone: student.phone, telegram: student.telegram, email: student.email