Class: StudentBase
- Inherits:
-
Object
- Object
- StudentBase
- Defined in:
- lib/student_base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#git ⇒ Object
readonly
Returns the value of attribute git.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #contact ⇒ Object
- #has_contact? ⇒ Boolean
- #has_git? ⇒ Boolean
-
#initialize(id: nil, git: nil) ⇒ StudentBase
constructor
A new instance of StudentBase.
- #last_name_initials ⇒ Object
- #short_info ⇒ Object
- #to_s ⇒ Object
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
#git ⇒ Object (readonly)
Returns the value of attribute git.
2 3 4 |
# File 'lib/student_base.rb', line 2 def git @git end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
2 3 4 |
# File 'lib/student_base.rb', line 2 def id @id end |
Instance Method Details
#contact ⇒ Object
13 14 15 |
# File 'lib/student_base.rb', line 13 def contact raise NotImplementedError, "Метод contact должен быть реализован в подклассе" end |
#has_contact? ⇒ Boolean
21 22 23 |
# File 'lib/student_base.rb', line 21 def has_contact? !contact.nil? end |
#has_git? ⇒ Boolean
25 26 27 |
# File 'lib/student_base.rb', line 25 def has_git? !git.nil? end |
#last_name_initials ⇒ Object
17 18 19 |
# File 'lib/student_base.rb', line 17 def last_name_initials raise NotImplementedError, "Метод last_name_initials должен быть реализован в подклассе" end |
#short_info ⇒ Object
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_s ⇒ Object
9 10 11 |
# File 'lib/student_base.rb', line 9 def to_s raise NotImplementedError, "Метод to_s должен быть реализован в подклассе" end |