refactor: rename contact_info method to get_first_contact for clarity

lab2
Artem-Darius Weber 3 days ago
parent 2932741c0e
commit 6da1bacfd5

@ -35,10 +35,10 @@ classDiagram
+ valid_email() : Boolean <<class>>
+ git_present() : Boolean
+ contact_present() : Boolean
+ contact_info() : String
+ get_first_contact() : String
+ git=(git : String) : void
- validate_id(id: String) : void
- validate_git(git : String) : void
- validate_id(id: String) : void <<class>>
- validate_git(git : String) : void <<class>>
- validate_contact(contact : Contact) : void
- valid_git?(git : String) : Boolean
- valid_id?(id : String) : Boolean

@ -7,7 +7,7 @@ require_relative 'binary_search_tree'
def test_classes
person = Person.new(id: '1', git: 'https://github.com/example', phone: '+798912465', telegram: '@example_user', email: 'test@example.com')
puts "Person Contact Info: #{person.contact_info}"
puts "Person Contact Info: #{person.get_first_contact}"
student = Student.new(
id: '2',
@ -22,7 +22,7 @@ def test_classes
)
puts "Student Full Info: #{student.to_s}"
puts "Student Initials: #{student.surname_and_initials}"
puts "Student Contact Info: #{student.contact_info}"
puts "Student Contact Info: #{student.get_first_contact}"
student_short = StudentShort.from_student(student)
puts "Student Short Info: #{student_short.to_s}"

@ -20,8 +20,8 @@ class Person
@phone || @telegram || @email
end
def contact_info
[@phone, @telegram, @email].compact.join(', ')
def get_first_contact
[@phone, @telegram, @email].compact.first
end
def self.valid_phone_number?(phone)

@ -56,7 +56,7 @@ class Student < Person
end
def get_info
"#{surname_and_initials}, Git: #{@git}, Contact: #{contact_info}, Birth Date: #{@birth_date}"
"#{surname_and_initials}, Git: #{@git}, Contact: #{get_first_contact}, Birth Date: #{@birth_date}"
end
def surname=(surname)

@ -38,7 +38,7 @@ class StudentShort < Person
end
def to_s
contact_info = contact_info()
contact_info = get_first_contact()
"#{@surname_initials}, Contact: #{contact_info}"
end

Loading…
Cancel
Save