Class: ShnaiderCode::StudentsListFormatterAdapter
- Inherits:
-
StudentsListAdapter
- Object
- StudentsListAdapter
- ShnaiderCode::StudentsListFormatterAdapter
- Defined in:
- lib/source/students_list_adapter.rb
Instance Method Summary collapse
- #add_student(student) ⇒ Object
- #count ⇒ Object
- #get_student(id) ⇒ Object
- #get_students(from, to) ⇒ Object
-
#initialize(formatter, filename) ⇒ StudentsListFormatterAdapter
constructor
A new instance of StudentsListFormatterAdapter.
- #remove_student(id) ⇒ Object
- #replace_student(id, student) ⇒ Object
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 |
#count ⇒ Object
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 |