From b23726d6461d90e68affcc120bb125aea39440ad Mon Sep 17 00:00:00 2001 From: Kanezoh Date: Tue, 10 Aug 2021 14:24:26 +0900 Subject: [PATCH] set history #push and #pop --- src/mechanize/history.cr | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/mechanize/history.cr b/src/mechanize/history.cr index b20272e..d3b4b54 100644 --- a/src/mechanize/history.cr +++ b/src/mechanize/history.cr @@ -6,4 +6,19 @@ class MechanizeCr::History < Array(MechanizeCr::Page) @max_size = max_size super end + + def push(page, uri = nil) + super page + while self.size > @max_size + shift + end + self + end + + def pop + if size == 0 + # TODO: raise error + end + page = super + end end