Sha256: 3fa4da00b51422e66fd7c1d48234f77f74c4ce844aeb1664f5e0cd50fe9411d3
Contents?: true
Size: 674 Bytes
Versions: 9
Compression:
Stored size: 674 Bytes
Contents
# frozen_string_literal: true require_relative "../hooks/hook_storage" module Kanal module Core module Helpers class Queue include Hooks attr_reader :hooks def initialize @items = [] @hooks = HookStorage.new hooks.register(:item_queued) # args arguments: item end def enqueue(element) @items.append element @hooks.call :item_queued, element end def dequeue @items.shift end def empty? @items.empty? end def remove(element) @items.delete(element) end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems