Sha256: 1975d28205d6a8b6d86e489b19ef5c8f15a87ea041b67ea248dd3c3e2509ec78

Contents?: true

Size: 1.87 KB

Versions: 3

Compression:

Stored size: 1.87 KB

Contents

module RubbishCode
    class StudentsListAdapter
        def get_student(id)
        end

        def remove_student(id)
        end

        def replace_student(id, student, data)
        end

        def get_students(from, to, data)
        end

        def add_student(student)
        end

        def count
        end
    end

    class StudentsListDBAdapter < StudentsListAdapter
        attr_private_accessor :database_list

        def initialize(database_list)
            self.database_list = database_list
        end

        def get_student(id)
            database_list.get_student(id)
        end

        def remove_student(id)
            database_list.remove_student(id)
        end

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

        def get_students(from, to)
            database_list.get_students_slice(from, to)
        end

        def add_student(student)
            database_list.add_student(student)
        end

        def count
            database_list.count()
        end
    end

    class StudentsListFormatterAdapter < StudentsListAdapter
        attr_private_accessor :formatter

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

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

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

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

        def get_students(from, to)
            count = to - from
            k = from / count

            formatter.get_students_slice(k, count)
        end

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

        def count
            formatter.count()
        end
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
Web_rubbish_code-1.0.2 lib/source/students_list_adapter.rb
Web_rubbish_code-1.0.1 lib/source/students_list_adapter.rb
Web_rubbish_code-1.0.0 lib/source/students_list_adapter.rb