Sha256: 4e71a8eefd3117e0760247fcd1ed7bb6494545d90a0b8c31b3337806ffe08d39
Contents?: true
Size: 1.19 KB
Versions: 3
Compression:
Stored size: 1.19 KB
Contents
module ShnaiderCode class StudentListFormat attr_private_accessor :students attr_accessor :formater def initialize(formater) self.formater = formater end def read_from(filename) self.students = formater.read_from(filename) end def write_to(filename) formater.write_to(filename, self.students) end def get_student(id) self.students.detect { |x| x.id == id .to_s } end def add_student(student) self.students << student end def delete_student(id) index = students.index(students.detect { |x| x.id == id.to_s }) self.students.delete_at(index) end def replace_student(id, student) self.students.map! { |x| x.id == id.to_s ? student : x } end def get_students_slice(k, count) from = [k * count, self.students.count].min to = [self.students.count, from + count].min end def count() self.students.count end def sort() self.students.sort_by(&:fio_info) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
shnaider_code-2.0.4 | lib/source/student_list_format.rb |
shnaider_code-2.0.3 | lib/source/student_list_format.rb |
shnaider_code-2.0.2 | lib/source/student_list_format.rb |