Sha256: 2741c6dedbaf44fe1519877774d9afba04749d4d30537e4e99fdaa23686d72f4

Contents?: true

Size: 1.07 KB

Versions: 9

Compression:

Stored size: 1.07 KB

Contents

module DataListObserver
    def notify(data)
        raise 'not implemented'
    end
end

module DataListNotifier
    attr_accessor :data_list_observers

    def notify
        raise 'not implemented'
    end
end

class DataList 
    attr_accessor :list
    attr_private_accessor :selected_objects
    def initialize(list:)
        self.data_list_observers = []
        self.list = list
    end

    def select(index)
        selected_objects << index
    end

    def get_selected_objects
        (0...list.size)
            .filter { |x| selected_objects.include? x }
    end

    def get_names
        raise "Метод не реализован"
    end

    def get_data
        raise "Метод не реализован"
    end
end

class DataList
    include DataListNotifier

    def notify
        data_list_observers.each { |observer|
            observer.notify(self.get_data)
        }
    end

    def add_observer(observer)
        self.data_list_observers << observer
    end

    def remove_observer(observer)
        self.data_list_observers.delete(observer) 
    end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
mc_delta-0.4.0 lib/source/data_list.rb
mc_delta-0.3.0 lib/source/data_list.rb
mc_delta-0.2.0 lib/source/data_list.rb
mc_delta-0.1.0 lib/source/data_list.rb
model_gem-0.2.0 lib/model_gem_source/data_list.rb
model_gem-0.1.9 lib/model_gem_source/data_list.rb
model_gem-0.1.8 lib/model_gem_source/data_list.rb
model_gem-0.1.7 ./model_gem_source/data_list.rb
model_gem-0.1.6 ./model_gem_source/data_list.rb