Skip to content

Instantly share code, notes, and snippets.

@bararchy
Created November 9, 2014 09:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bararchy/74b789f46e2dad137a6b to your computer and use it in GitHub Desktop.
Save bararchy/74b789f46e2dad137a6b to your computer and use it in GitHub Desktop.
@cookies = []
@cookies << ["1234", Time.now, "this will be deleted"]
sleep 1
@cookies << ["1234", Time.now + 1, "this also should be deleted"]
sleep 1
@cookies << ["1234", Time.now + 60, "this wont be deleted"]
sleep 5
puts "This is the whole array: ", @cookies
for cookie in @cookies
puts "This is one cookie in the array: ", cookie[1], Time.now
if cookie[1] < Time.now
@cookies.reject! {|entry| entry == cookie }
end
end
puts "This is what left: ", @cookies
@zenspider
Copy link

cookies = []

cookies << ["1234", Time.now, "this will be deleted"]
sleep 1
cookies << ["1234", Time.now + 1, "this also should be deleted"]
sleep 1
cookies << ["1234", Time.now + 60, "this wont be deleted"]

p :before => cookies

now = Time.now
cookies.reject! { |cookie| cookie[1] < now }

p :after => cookies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment