Implement limit

This commit is contained in:
Tim Kächele 2023-10-27 14:56:19 +02:00
parent 59420ee879
commit da31634600

40
lib/rex/limit.rb Normal file
View File

@ -0,0 +1,40 @@
module Rex
class Limit
def initialize(price)
@price = price
@first_order = nil
@last_order = nil
@order_count = 0
end
def peek_first_order
@first_order
end
def pop_first_order
order = @first_order
@first_order = @first_order.next_order
if @first_order == nil
@last_order = nil
end
@order_count -= 1
order
end
def add_order(order)
if empty?
@first_order = order
@last_order = order
else
@last_order.next_order = order
@last_order = order
end
@order_count += 1
end
def empty?
@order_count == 0
end
end
end