Sha256: 8ef050e70e6c5dc95f5285596746c0cbc0a0c0d66943e0bbd95ebabebe258340

Contents?: true

Size: 940 Bytes

Versions: 6

Compression:

Stored size: 940 Bytes

Contents

require_relative 'StudentBase'
class StudentShort < StudentBase

	public_class_method :new

	#У нас уже есть некоторые гет\сет в базе, зачем же ещё?
	private
	attr_writer :fio, :contact, :git, :id

	public
	attr_reader :fio, :contact, :git, :id

	def self.from_student_class(student)
		puts("In studentShort: #{student.to_s}")
		StudentShort.new(student.id, student.get_info)
	end

	def initialize(id, str)
		info_short = str.split(',')
						.map{|x| x.split(':')}
						.map{|x| [x[0].to_sym, x[1]]}
						.to_h
		raise ArgumentError, 'Missing fields: fio' if info_short[:fio].nil?
		print(info_short)
		self.id=id
		self.fio = info_short[:fio]
		self.git = info_short[:git]
		info_short.delete_if{|k,v| k==:fio||k==:git}
		self.contact = info_short.values.first
	end


	def to_s

		[
			"#{id}, #{fio}, #{git}, #{contact}"
		].compact.join(' ')
	end
	
end

Version data entries

6 entries across 6 versions & 4 rubygems

Version Path
mc_gem3-1.0.2 lib/source/Student_short.rb
mc_gem3-1.0.0 lib/source/Student_short.rb
mc_gem2-1.1.5 lib/source/Student_short.rb
mc_gem2-1.1.4 lib/source/Student_short.rb
mvcStudentXD-1.0.1 lib/Student_short.rb
model_XD-0.1.0 lib/Student_short.rb