Sha256: 987c0839a93c61a63b5ea6d711f057b3c9ecade07e6433c39b863ae3e89f8b20

Contents?: true

Size: 543 Bytes

Versions: 5

Compression:

Stored size: 543 Bytes

Contents

module Vedeu

  # First-in first-out storage.
  #
  #   in -> [3] -> [2] -> [1] -> out
  #
  class FifoStore

    include Vedeu::Store

    # @param storage [Array]
    # @return [Vedeu::FifoStore]
    def initialize(storage = [])
      @storage = storage
    end

    # @return [Object]
    def load
      storage.pop
    end

    # @param data [Object]
    # @return [Array<Object>]
    def save(data)
      storage.unshift(data)
    end

    private

    # @return [Array]
    def in_memory
      []
    end

  end # FifoStore

end # Vedeu

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vedeu-0.4.18 lib/vedeu/storage/fifo_store.rb
vedeu-0.4.17 lib/vedeu/storage/fifo_store.rb
vedeu-0.4.16 lib/vedeu/storage/fifo_store.rb
vedeu-0.4.15 lib/vedeu/storage/fifo_store.rb
vedeu-0.4.14 lib/vedeu/storage/fifo_store.rb