Sha256: 677c00ee7b150bb11b4ebc55ce6db0df2841419a24d4349539fdad89da6b4a89

Contents?: true

Size: 899 Bytes

Versions: 1

Compression:

Stored size: 899 Bytes

Contents

#popper = Qfill::ListSet.new(
#  Qfill::List.new( :name => "High List",
#                       :elements => [Thing1, Thing3],
#                       :filter => filter1 ) )
module Qfill
  class ListSet

    attr_accessor :queues, :current_index

    def initialize(*args)
      raise ArgumentError, "Missing required arguments for #{self.class}.new(queues)" unless args.length > 0
      @queues = args
      @current_index = 0
    end

    def [](key)
      return self.queues.find { |queue| queue.name == key }
    end

    def index_of(queue_name)
      index = self.queues.index { |queue| queue.name == queue_name }
      return index if index
      raise "Fuck #{index} index is missing for #{queue_name}"
    end

    def reset!
      self.current_index = 0
    end

    def get_total_elements
      self.queues.inject(0) {|counter, queue| counter += queue.elements.length}
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
qfill-0.0.4 lib/qfill/list_set.rb