|
|
@ -1,14 +1,22 @@
|
|
|
|
class Student
|
|
|
|
class Student
|
|
|
|
attr_accessor :id, :surname, :name, :patronymic, :phone, :telegram, :email, :git
|
|
|
|
attr_accessor :id, :surname, :name, :patronymic, :phone, :telegram, :email, :git
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def self.valid_phone_number?(phone)
|
|
|
|
|
|
|
|
phone.match?(/\A\+?[0-9]{10,15}\z/)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def initialize(args = {})
|
|
|
|
def initialize(args = {})
|
|
|
|
@surname = args.fetch(:surname)
|
|
|
|
@surname = args.fetch(:surname)
|
|
|
|
@name = args.fetch(:name)
|
|
|
|
@name = args.fetch(:name)
|
|
|
|
@patronymic = args.fetch(:patronymic)
|
|
|
|
@patronymic = args.fetch(:patronymic)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@id = args[:id] || nil
|
|
|
|
@id = args[:id] || nil
|
|
|
|
@phone = args[:phone] || nil
|
|
|
|
|
|
|
|
|
|
|
|
@phone = args[:phone]
|
|
|
|
|
|
|
|
if @phone && !Student.valid_phone_number?(@phone)
|
|
|
|
|
|
|
|
raise ArgumentError, "Invalid phone number format: #{@phone}"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
@telegram = args[:telegram] || nil
|
|
|
|
@telegram = args[:telegram] || nil
|
|
|
|
@email = args[:email] || nil
|
|
|
|
@email = args[:email] || nil
|
|
|
|
@git = args[:git] || nil
|
|
|
|
@git = args[:git] || nil
|
|
|
|