Implement limit
This commit is contained in:
parent
59420ee879
commit
da31634600
40
lib/rex/limit.rb
Normal file
40
lib/rex/limit.rb
Normal 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
|
Loading…
Reference in New Issue
Block a user