class Student_short
Attributes
Public Class Methods
Source
# File lib/models/student_short/student_short.rb, line 7 def initialize(full_name:, git:, contact:, id: nil) self.id = id self.full_name = full_name self.git = git self.set_contacts(contact) end
Source
# File lib/models/student_short/student_short.rb, line 25 def self.new_from_string(id, string) hash = self.parse_string(string) contact = '' if hash['telegram'] then contact = "telegram: #{hash['telegram']}" elsif hash['email'] contact = "email: #{hash['email']}" else contact = "phone_number #{hash['phone_number']}" end self.new( id: id.to_i, full_name: hash['full_name'], git: hash['git'], contact: contact ) end
constructor from string
Source
# File lib/models/student_short/student_short.rb, line 15 def self.new_from_student_obj(student) self.new( id: student.id.to_i, full_name: student.get_full_name.slice(11..-1), git: student.git, contact: student.get_any_contact ) end
constructor from Student
object
Source
# File lib/models/student_short/student_short.rb, line 95 def self.valid_name?(name) name =~ /^[А-ЯЁ][а-яё]{1,}(-[А-ЯЁ][а-яё]{1,})?\s[А-ЯЁ].\s?[А-ЯЁ].$/ end
full name validation
Public Instance Methods
Source
# File lib/models/student_short/student_short.rb, line 54 def get_any_contact @contact end
Source
# File lib/models/student_short/student_short.rb, line 50 def validate? super && self.validate_contacts? end
validate git and contacts
Calls superclass method
Person#validate?
Source
# File lib/models/student_short/student_short.rb, line 45 def validate_contacts? !(self.get_any_contact.nil? || self.get_any_contact == "") end
checking for contacts availability