Sha256: 1a7892fa8ef94ddc7a57ef33fc7c98187d375cfecd50695bfe9c978476524b62

Contents?: true

Size: 1.29 KB

Versions: 14

Compression:

Stored size: 1.29 KB

Contents

require 'json'
class StudentBase
	private_class_method :new

	def self.validate_phone?(phone)
		return phone.match(/^\+?[7,8] ?\(?\d{3}\)? ?\d{3}-?\d{2}-?\d{2}$/)
	end

	def self.validate_email?(email)
		return email.match(/^[A-Za-z0-9\-_]+@[A-Za-z]+(\.[A-Za-z]+)?\.[A-Za-z]+$/)
	end

	def self.validate_git_tg?(acc_name)
		return acc_name.match(/^@[A-Za-z0-9\-_]+$/)
	end

	def self.validate_name?(prof_name)
		return prof_name.match(/(^[А-Я][а-я]+$)|(^[A-Z][a-z]+$)/)
	end

	def valid_cont?
		!email.nil? || !telegram.nil? || !phone.nil?
	end

	def validate?
		!git.nil? && valid_cont?
	end

	def initialize(last_name, first_name, parental_name)
		self.last_name = last_name
		self.first_name = first_name
		self.parental_name = parental_name
	end

	def first_name=(first_name1)
		raise ArgumentError, "ERROR first_name=#{first_name1}" unless StudentBase.validate_name?(first_name1)
		@first_name=first_name1
	end

	def last_name=(last_name1)
		raise ArgumentError, "ERROR last_name=#{last_name1}" unless StudentBase.validate_name?(last_name1)
		@last_name=last_name1
	end

	def parental_name=(parental_name1)
		raise ArgumentError, "ERROR parental_name=#{parental_name1}" unless StudentBase.validate_name?(parental_name1)
		@parental_name=parental_name1
	end

end

Version data entries

14 entries across 14 versions & 5 rubygems

Version Path
mc_gem3-1.0.2 lib/source/StudentBase.rb
mc_gem3-1.0.0 lib/source/StudentBase.rb
mc_gem2-1.1.5 lib/source/StudentBase.rb
mc_gem2-1.1.4 lib/source/StudentBase.rb
mvcStudentXD-1.2.3 lib/source/model/StudentBase.rb
mc_gem-0.0.1 mc_gem/lib/source/model/StudentBase.rb
mvcStudentXD-1.2.2 lib/source/model/StudentBase.rb
mvcStudentXD-1.2.1 mvcStudentXD/lib/source/model/StudentBase.rb
mvcStudentXD-1.2.0 lib/source/model/StudentBase.rb
mvcStudentXD-1.1.3 lib/source/model/StudentBase.rb
mvcStudentXD-1.1.2 lib/model/StudentBase.rb
mvcStudentXD-1.1.1 lib/model/StudentBase.rb
mvcStudentXD-1.0.1 lib/StudentBase.rb
model_XD-0.1.0 lib/StudentBase.rb