Class: StudentListFileAdapter
- Inherits:
-
Object
- Object
- StudentListFileAdapter
- Defined in:
- lib/source/repositories/student_list_file_adapter.rb
Instance Method Summary collapse
-
#add_student(student) ⇒ Object
добавление студента.
-
#initialize(data_type, file_path) ⇒ StudentListFileAdapter
constructor
A new instance of StudentListFileAdapter.
-
#k_n_student_short_list(k, n, data_list) ⇒ Object
получение n элементов k страницы.
-
#remove_student(student_id) ⇒ Object
удаление студента по id.
-
#replace_student(student_id, student) ⇒ Object
замена студента по id.
-
#student_by_id(student_id) ⇒ Object
получить студента по id.
-
#student_count ⇒ Object
подсчет количества студентов.
Constructor Details
#initialize(data_type, file_path) ⇒ StudentListFileAdapter
Returns a new instance of StudentListFileAdapter.
5 6 7 8 9 |
# File 'lib/source/repositories/student_list_file_adapter.rb', line 5 def initialize(data_type, file_path) @file = StudentListBase.new(data_type) @file.load_from_file(file_path) @file_path = file_path end |
Instance Method Details
#add_student(student) ⇒ Object
добавление студента
16 17 18 19 |
# File 'lib/source/repositories/student_list_file_adapter.rb', line 16 def add_student(student) @file.add_student(student) @file.save_to_file(@file_path) end |
#k_n_student_short_list(k, n, data_list) ⇒ Object
получение n элементов k страницы
39 40 41 |
# File 'lib/source/repositories/student_list_file_adapter.rb', line 39 def k_n_student_short_list(k,n, data_list) @file.k_n_student_short_list(k, n, data_list) end |
#remove_student(student_id) ⇒ Object
удаление студента по id
22 23 24 25 |
# File 'lib/source/repositories/student_list_file_adapter.rb', line 22 def remove_student(student_id) @file.remove_student(student_id) @file.save_to_file(@file_path) end |
#replace_student(student_id, student) ⇒ Object
замена студента по id
28 29 30 31 |
# File 'lib/source/repositories/student_list_file_adapter.rb', line 28 def replace_student(student_id, student) @file.replace_student(student_id,student) @file.save_to_file(@file_path) end |
#student_by_id(student_id) ⇒ Object
получить студента по id
11 12 13 |
# File 'lib/source/repositories/student_list_file_adapter.rb', line 11 def student_by_id(student_id) @file.student_by_id(student_id) end |
#student_count ⇒ Object
подсчет количества студентов
34 35 36 |
# File 'lib/source/repositories/student_list_file_adapter.rb', line 34 def student_count @file.student_count end |