Class: ShnaiderCode::StudentsListFormatterAdapter

Inherits:
StudentsListAdapter show all
Defined in:
lib/source/students_list_adapter.rb

Instance Method Summary collapse

Constructor Details

#initialize(formatter, filename) ⇒ StudentsListFormatterAdapter

Returns a new instance of StudentsListFormatterAdapter.



57
58
59
60
# File 'lib/source/students_list_adapter.rb', line 57

def initialize(formatter, filename)
    self.formatter = formatter
    formatter.read_from(filename)
end

Instance Method Details

#add_student(student) ⇒ Object



81
82
83
# File 'lib/source/students_list_adapter.rb', line 81

def add_student(student)
    formatter.add_student(student)
end

#countObject



85
86
87
# File 'lib/source/students_list_adapter.rb', line 85

def count
    formatter.count()
end

#get_student(id) ⇒ Object



62
63
64
# File 'lib/source/students_list_adapter.rb', line 62

def get_student(id)
    formatter.get_student(id)
end

#get_students(from, to) ⇒ Object



74
75
76
77
78
79
# File 'lib/source/students_list_adapter.rb', line 74

def get_students(from, to)
    count = to - from
    k = from / count
    
    formatter.get_students_slice(k, count)
end

#remove_student(id) ⇒ Object



66
67
68
# File 'lib/source/students_list_adapter.rb', line 66

def remove_student(id)
    formatter.delete_student(id)
end

#replace_student(id, student) ⇒ Object



70
71
72
# File 'lib/source/students_list_adapter.rb', line 70

def replace_student(id, student)
    formatter.replace_student(id, student)
end