Class: StudentFileAdapter

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

Instance Method Summary collapse

Constructor Details

#initialize(type_file, file_address) ⇒ StudentFileAdapter

Returns a new instance of StudentFileAdapter.



4
5
6
7
8
# File 'lib/source/database/student_file_adapter.rb', line 4

def initialize(type_file,file_address)
  @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/database/student_file_adapter.rb', line 14

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

#count_student ⇒ Object



30
31
32
# File 'lib/source/database/student_file_adapter.rb', line 30

def count_student
  @file.count_student
end

#delete_student(id_student) ⇒ Object



19
20
21
22
# File 'lib/source/database/student_file_adapter.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



34
35
36
# File 'lib/source/database/student_file_adapter.rb', line 34

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
28
# File 'lib/source/database/student_file_adapter.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/database/student_file_adapter.rb', line 10

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