refactor: implement surname_initials method and update references for consistency

lab2
Artem-Darius Weber 3 days ago
parent bffdd2f072
commit 2126888d8a

@ -30,6 +30,7 @@ classDiagram
+ phone=(String) : Boolean + phone=(String) : Boolean
+ telegram=(String) : Boolean + telegram=(String) : Boolean
+ email=(String) : Boolean + email=(String) : Boolean
+ surname_initials() : NotImplementedError
+ valid_phone_number() : Boolean <<class>> + valid_phone_number() : Boolean <<class>>
+ valid_telegram() : Boolean <<class>> + valid_telegram() : Boolean <<class>>
+ valid_email() : Boolean <<class>> + valid_email() : Boolean <<class>>

@ -21,7 +21,7 @@ def test_classes
email: 'ivanov@example.com' email: 'ivanov@example.com'
) )
puts "Student Full Info: #{student.to_s}" 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}" puts "Student Contact Info: #{student.get_first_contact}"
student_short = StudentShort.from_student(student) student_short = StudentShort.from_student(student)

@ -12,6 +12,10 @@ class Person
@git = git @git = git
end end
def surname_initials
raise NotImplementedError, "#{self.class} must implement the 'surname_initials' method"
end
def git_present? def git_present?
!@git.nil? && !@git.empty? !@git.nil? && !@git.empty?
end end

@ -12,7 +12,7 @@ class StudentShort < Person
def self.from_student(student) def self.from_student(student)
new( new(
id: student.id, id: student.id,
surname_initials: student.surname_and_initials, surname_initials: student.surname_initials,
phone: student.phone, phone: student.phone,
telegram: student.telegram, telegram: student.telegram,
email: student.email email: student.email

Loading…
Cancel
Save