Class: StudentFileAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/source/studentFileAdapter.rb

Instance Method Summary collapse

Constructor Details

#initialize(type_file, file_address) ⇒ StudentFileAdapter

Returns a new instance of StudentFileAdapter.



3
4
5
6
7
8
# File 'lib/source/studentFileAdapter.rb', line 3

def initialize(type_file,file_address)
  #обращаемся к экземплярам класса StudentListBase
  @file = StudentListBase.new(type_file)
  @file.load_from_file(file_address)
  @file_address = file_address
end

Instance Method Details

#add_student(student) ⇒ Object



14
15
16
17
# File 'lib/source/studentFileAdapter.rb', line 14

def add_student(student)
  @file.add_student(student)
  @file.save_to_file(@file_address)
end

#count_studentObject



29
30
31
# File 'lib/source/studentFileAdapter.rb', line 29

def count_student
  @file.count_student
end

#delete_student(id_student) ⇒ Object



19
20
21
22
# File 'lib/source/studentFileAdapter.rb', line 19

def delete_student(id_student)
  @file.delete_student(id_student)
  @file.save_to_file(@file_address)
end

#get_k_n_student_short_list(page, n, data_list) ⇒ Object



33
34
35
# File 'lib/source/studentFileAdapter.rb', line 33

def get_k_n_student_short_list(page,n, data_list)
  @file.get_k_n_student_short_list(page, n, data_list)
end

#replace_student(id_student, student) ⇒ Object



24
25
26
27
# File 'lib/source/studentFileAdapter.rb', line 24

def replace_student(id_student, student)
  @file.replace_student(id_student, student)
  @file.save_to_file(@file_address)
end

#student_by_id(id_student) ⇒ Object



10
11
12
# File 'lib/source/studentFileAdapter.rb', line 10

def student_by_id(id_student)
  @file.student_by_id(id_student)
end