Sha256: 1f0555ce051a6e12fbc93549e5591ed199bad77bbe0829611582f68243b99700
Contents?: true
Size: 1.36 KB
Versions: 2
Compression:
Stored size: 1.36 KB
Contents
require 'json' require_relative 'student' class StudentShort attr_reader :id,:surname,:short_name, :git, :contact def initialize(student) @id = student.id @surname = student.surname @short_name = "#{student.first_name[0]}. #{student.middle_name[0]}." @git = student.git unless student.git.nil? @contact = student.set_contacts(phone_number: student.phone_number, mail:student.mail,telegram: student.telegram) end def self.from_str(id,str) res = JSON.parse(str) Student_Short.new(Student.new(first_name: res['fisrst_name'], middle_name:res['middle_name'], surname:res['surname'], id:id, phone_number: result['phone_number'], git: result['git'], mail: result['mail'],telegram: result['telegram'])) end def to_s res = short_name_initials res += " id=#{id}" unless id.nil? res += " git=#{git}" unless git.nil? res += " #{contact}" unless contact.nil? res end def short_name_initials "#{@surname} #{@short_name}" end #валидатор def validate? exist_git? and exist_contact? end def exist_git? !self.git.nil? end def exist_contact? !(self.phone_number.nil? and self.telegram.nil? and self.mail.nil?) end end # frozen_string_literal: true
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
shanti555890-1.1.5 | lib/source/student/student_short.rb |
shanti555890-1.1.4 | lib/source/student/student_short.rb |