Class: StudentBase

Inherits:
Object
  • Object
show all
Defined in:
lib/student_base.rb

Direct Known Subclasses

Student, StudentShort

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: nil, git: nil) ⇒ StudentBase

Returns a new instance of StudentBase.



4
5
6
7
# File 'lib/student_base.rb', line 4

def initialize(id: nil, git: nil)
    @id = id
    @git = git
end

Instance Attribute Details

#gitObject (readonly)

Returns the value of attribute git.



2
3
4
# File 'lib/student_base.rb', line 2

def git
  @git
end

#idObject (readonly)

Returns the value of attribute id.



2
3
4
# File 'lib/student_base.rb', line 2

def id
  @id
end

Instance Method Details

#contactObject

Raises:

  • (NotImplementedError)


13
14
15
# File 'lib/student_base.rb', line 13

def contact
    raise NotImplementedError, "Метод contact должен быть реализован в подклассе"
end

#has_contact?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/student_base.rb', line 21

def has_contact?
    !contact.nil?
end

#has_git?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/student_base.rb', line 25

def has_git?
    !git.nil?
end

#last_name_initialsObject

Raises:

  • (NotImplementedError)


17
18
19
# File 'lib/student_base.rb', line 17

def last_name_initials
    raise NotImplementedError, "Метод last_name_initials должен быть реализован в подклассе"
end

#short_infoObject



29
30
31
32
33
34
# File 'lib/student_base.rb', line 29

def short_info
    info = "ID: #{id}, ФИО: #{last_name_initials}"
    info += ", Контакт: #{contact}" if has_contact?
    info += ", Git: #{git}" if has_git?
    info
end

#to_sObject

Raises:

  • (NotImplementedError)


9
10
11
# File 'lib/student_base.rb', line 9

def to_s
    raise NotImplementedError, "Метод to_s должен быть реализован в подклассе"
end