Class: Person::Student
Overview
Instance Attribute Summary collapse
-
#mat_nr ⇒ Integer
readonly
The matriculation number.
Attributes inherited from Person
Class Method Summary collapse
-
.create_from_attribute_list(list) ⇒ Object
singleton method to create a Student from a n array of strings.
Instance Method Summary collapse
-
#initialize(name = "def_student", id = PersonIDGenerator.generate_new_id, mat_nr) ⇒ Student
constructor
initialization.
-
#to_file ⇒ String
overwrites the method Person#to_file to create an output string for the output file with all its attributes.
-
#to_string ⇒ String
overwrites the method Person#to_string to create an output string with all its attributes.
Constructor Details
#initialize(name = "def_student", id = PersonIDGenerator.generate_new_id, mat_nr) ⇒ Student
initialization
15 16 17 18 19 |
# File 'lib/entity/person/student.rb', line 15 def initialize(name="def_student", id=PersonIDGenerator.generate_new_id, mat_nr) super(name, id) @mat_nr = mat_nr end |
Instance Attribute Details
#mat_nr ⇒ Integer (readonly)
Returns the matriculation number.
9 10 11 |
# File 'lib/entity/person/student.rb', line 9 def mat_nr @mat_nr end |
Class Method Details
.create_from_attribute_list(list) ⇒ Object
singleton method to create a Person::Student from a n array of strings
41 42 43 44 45 |
# File 'lib/entity/person/student.rb', line 41 def self.create_from_attribute_list(list) id = list[1].to_i mat_nr = list[2].to_i self.new(list[0], id, mat_nr) end |
Instance Method Details
#to_file ⇒ String
overwrites the method Person#to_file to create an output string for the output file with all its attributes
32 33 34 |
# File 'lib/entity/person/student.rb', line 32 def to_file super.concat(";#{@mat_nr}") end |
#to_string ⇒ String
overwrites the method Person#to_string to create an output string with all its attributes
24 25 26 |
# File 'lib/entity/person/student.rb', line 24 def to_string super.concat(" and Matriculation: #{@mat_nr}") end |