Class: StudentListDB
- Inherits:
-
Object
- Object
- StudentListDB
- Defined in:
- lib/source/student_list_db.rb
Constant Summary collapse
- @@instance =
nil
Instance Attribute Summary collapse
-
#database ⇒ Object
Returns the value of attribute database.
Class Method Summary collapse
Instance Method Summary collapse
- #add_student(student) ⇒ Object
- #count ⇒ Object
- #get_student(id) ⇒ Object
- #get_students_pag(k, n, data) ⇒ Object
-
#initialize ⇒ StudentListDB
constructor
A new instance of StudentListDB.
- #remove_student(id) ⇒ Object
- #replace_student(id, student) ⇒ Object
Constructor Details
#initialize ⇒ StudentListDB
Returns a new instance of StudentListDB.
14 15 16 |
# File 'lib/source/student_list_db.rb', line 14 def initialize self.database = StudentDB.new() end |
Instance Attribute Details
#database ⇒ Object
Returns the value of attribute database.
5 6 7 |
# File 'lib/source/student_list_db.rb', line 5 def database @database end |
Class Method Details
.instance ⇒ Object
9 10 11 |
# File 'lib/source/student_list_db.rb', line 9 def self.instance @@instance ||= StudentListDB.new end |
Instance Method Details
#add_student(student) ⇒ Object
30 31 32 |
# File 'lib/source/student_list_db.rb', line 30 def add_student(student) database.add_student(student.to_hash) end |
#count ⇒ Object
38 39 40 |
# File 'lib/source/student_list_db.rb', line 38 def count database.count end |
#get_student(id) ⇒ Object
18 19 20 |
# File 'lib/source/student_list_db.rb', line 18 def get_student(id) Student.from_hash(database.select_by_id(id).transform_keys(&:to_sym)) end |
#get_students_pag(k, n, data) ⇒ Object
34 35 36 |
# File 'lib/source/student_list_db.rb', line 34 def get_students_pag(k, n, data) database.get_students_pag(k, n, data) end |
#remove_student(id) ⇒ Object
22 23 24 |
# File 'lib/source/student_list_db.rb', line 22 def remove_student(id) database.remove_by_id(id) end |
#replace_student(id, student) ⇒ Object
26 27 28 |
# File 'lib/source/student_list_db.rb', line 26 def replace_student(id, student) database.replace_by_id(id, student) end |