class Utils::Grepper::Queue

def data

Returns:
  • (Array) - a duplicate of the internal data array
def data
  @data.dup
end

def initialize(max_size)

Parameters:
  • max_size (Integer) -- the maximum size limit for the data storage
def initialize(max_size)
  @max_size, @data = max_size, []
end

def push(x)

Returns:
  • (Queue) - returns self to allow for method chaining

Parameters:
  • x (Object) -- the element to be added to the queue
def push(x)
  @data.shift if @data.size > @max_size
  @data << x
  self
end