Class: StudentShort
- Inherits:
-
StudentBase
- Object
- StudentBase
- StudentShort
- Defined in:
- lib/Student_short.rb
Instance Attribute Summary collapse
-
#contact ⇒ Object
readonly
Returns the value of attribute contact.
-
#fio ⇒ Object
readonly
Returns the value of attribute fio.
-
#git ⇒ Object
readonly
Returns the value of attribute git.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id, str) ⇒ StudentShort
constructor
A new instance of StudentShort.
- #to_s ⇒ Object
Methods inherited from StudentBase
#first_name=, #last_name=, #parental_name=, #valid_cont?, #validate?, validate_email?, validate_git_tg?, validate_name?, validate_phone?
Constructor Details
#initialize(id, str) ⇒ StudentShort
Returns a new instance of StudentShort.
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/Student_short.rb', line 18 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 |
Instance Attribute Details
#contact ⇒ Object
Returns the value of attribute contact.
11 12 13 |
# File 'lib/Student_short.rb', line 11 def contact @contact end |
#fio ⇒ Object
Returns the value of attribute fio.
11 12 13 |
# File 'lib/Student_short.rb', line 11 def fio @fio end |
#git ⇒ Object
Returns the value of attribute git.
11 12 13 |
# File 'lib/Student_short.rb', line 11 def git @git end |
#id ⇒ Object
Returns the value of attribute id.
11 12 13 |
# File 'lib/Student_short.rb', line 11 def id @id end |
Class Method Details
.from_student_class(student) ⇒ Object
13 14 15 16 |
# File 'lib/Student_short.rb', line 13 def self.from_student_class(student) puts("In studentShort: #{student.to_s}") StudentShort.new(student.id, student.get_info) end |
Instance Method Details
#to_s ⇒ Object
33 34 35 36 37 38 |
# File 'lib/Student_short.rb', line 33 def to_s [ "#{id}, #{fio}, #{git}, #{contact}" ].compact.join(' ') end |