Class: Student_short

Inherits:
Super_Student show all
Defined in:
lib/files/student_short.rb

Instance Attribute Summary collapse

Attributes inherited from Super_Student

#Father_name, #Name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Super_Student

acc_valid?, id_valid?, name_valid?

Constructor Details

#initialize(id:, surname:, initials:, git:, contact:) ⇒ Student_short

Returns a new instance of Student_short.



6
7
8
9
10
11
12
# File 'lib/files/student_short.rb', line 6

def initialize(id:, surname:, initials:, git:, contact:)
  @ID = id
  @Surname = surname
  @Initials = initials
  @Git = git
  @Contact = contact
end

Instance Attribute Details

#ContactObject (readonly)

Returns the value of attribute Contact.



5
6
7
# File 'lib/files/student_short.rb', line 5

def Contact
  @Contact
end

#GitObject (readonly)

Returns the value of attribute Git.



5
6
7
# File 'lib/files/student_short.rb', line 5

def Git
  @Git
end

#IDObject (readonly)

Returns the value of attribute ID.



5
6
7
# File 'lib/files/student_short.rb', line 5

def ID
  @ID
end

#InitialsObject (readonly)

Returns the value of attribute Initials.



5
6
7
# File 'lib/files/student_short.rb', line 5

def Initials
  @Initials
end

#SurnameObject (readonly)

Returns the value of attribute Surname.



5
6
7
# File 'lib/files/student_short.rb', line 5

def Surname
  @Surname
end

Class Method Details

.from_student(student) ⇒ Object



14
15
16
# File 'lib/files/student_short.rb', line 14

def self.from_student(student)
  Student_short.new(id:student.ID, surname:student.Surname, initials:"#{student.Name[0]}. #{student.Father_name[0]}.", git:student.Git, contact:student.contact)
end

.parse_str(str) ⇒ Object



18
19
20
# File 'lib/files/student_short.rb', line 18

def self.parse_str(str)
  Student_short.from_student(Student.parse_str(str))
end

Instance Method Details

#contactObject



34
35
36
# File 'lib/files/student_short.rb', line 34

def contact
  @Contact
end

#contact?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/files/student_short.rb', line 42

def contact?
  !@Contact.nil?
end

#getInfoObject



38
39
40
# File 'lib/files/student_short.rb', line 38

def getInfo
  return self.short_name+@Git
end

#short_nameObject



22
23
24
# File 'lib/files/student_short.rb', line 22

def short_name
  "#{@Surname} #{@Initials}"
end

#to_sObject



26
27
28
29
30
31
32
# File 'lib/files/student_short.rb', line 26

def to_s
  result = short_name
  result += ", id=#{@ID} " unless @ID.nil?
  result += ", git=#{@Git} " unless @Git.nil?
  result += @Contact unless @Contact.nil?
  result
end