Sha256: fd93fe97254369eec90d9d5c5bcee02c7bca2e26a36b479647f5cb812a4cd552

Contents?: true

Size: 1.26 KB

Versions: 6

Compression:

Stored size: 1.26 KB

Contents

module McDelta
    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
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
shnaider_code-2.0.1 lib/source/data_list.rb
shnaider_code-2.0.0 lib/source/data_list.rb
mc_delta-1.0.0 lib/source/data_list.rb
mc_delta-0.9.0 lib/source/data_list.rb
mc_delta-0.8.0 lib/source/data_list.rb
mc_delta-0.7.0 lib/source/data_list.rb