|
|
@ -1,18 +1,18 @@
|
|
|
|
require_relative 'person'
|
|
|
|
require_relative 'person'
|
|
|
|
|
|
|
|
|
|
|
|
class StudentShort < Person
|
|
|
|
class StudentShort < Person
|
|
|
|
attr_reader :name_initials
|
|
|
|
attr_reader :surname_initials
|
|
|
|
|
|
|
|
|
|
|
|
def initialize(id:, name_initials:, phone: nil, telegram: nil, email: nil)
|
|
|
|
def initialize(id:, surname_initials:, phone: nil, telegram: nil, email: nil)
|
|
|
|
super(id: id, phone: phone, telegram: telegram, email: email)
|
|
|
|
super(id: id, phone: phone, telegram: telegram, email: email)
|
|
|
|
@name_initials = name_initials
|
|
|
|
@surname_initials = surname_initials
|
|
|
|
freeze
|
|
|
|
freeze
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def self.from_student(student)
|
|
|
|
def self.from_student(student)
|
|
|
|
new(
|
|
|
|
new(
|
|
|
|
id: student.id,
|
|
|
|
id: student.id,
|
|
|
|
name_initials: student.surname_and_initials,
|
|
|
|
surname_initials: student.surname_and_initials,
|
|
|
|
phone: student.phone,
|
|
|
|
phone: student.phone,
|
|
|
|
telegram: student.telegram,
|
|
|
|
telegram: student.telegram,
|
|
|
|
email: student.email
|
|
|
|
email: student.email
|
|
|
@ -23,14 +23,14 @@ class StudentShort < Person
|
|
|
|
parts = info_string.split(',').map(&:strip)
|
|
|
|
parts = info_string.split(',').map(&:strip)
|
|
|
|
raise ArgumentError, 'Invalid info string format' if parts.size < 2
|
|
|
|
raise ArgumentError, 'Invalid info string format' if parts.size < 2
|
|
|
|
|
|
|
|
|
|
|
|
name_initials = parts[0]
|
|
|
|
surname_initials = parts[0]
|
|
|
|
contact_string = parts[1].split(': ', 2).last.strip
|
|
|
|
contact_string = parts[1].split(': ', 2).last.strip
|
|
|
|
|
|
|
|
|
|
|
|
phone, telegram, email = parse_contact_string(contact_string)
|
|
|
|
phone, telegram, email = parse_contact_string(contact_string)
|
|
|
|
|
|
|
|
|
|
|
|
new(
|
|
|
|
new(
|
|
|
|
id: id,
|
|
|
|
id: id,
|
|
|
|
name_initials: name_initials,
|
|
|
|
surname_initials: surname_initials,
|
|
|
|
phone: phone,
|
|
|
|
phone: phone,
|
|
|
|
telegram: telegram,
|
|
|
|
telegram: telegram,
|
|
|
|
email: email
|
|
|
|
email: email
|
|
|
@ -39,7 +39,7 @@ class StudentShort < Person
|
|
|
|
|
|
|
|
|
|
|
|
def to_s
|
|
|
|
def to_s
|
|
|
|
contact_info = get_first_contact()
|
|
|
|
contact_info = get_first_contact()
|
|
|
|
"#{@name_initials}, Contact: #{contact_info}"
|
|
|
|
"#{@surname_initials}, Contact: #{contact_info}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
private
|
|
|
|