diff --git a/src/mechanize/history.cr b/src/mechanize/history.cr index fed9a40..3588ed0 100644 --- a/src/mechanize/history.cr +++ b/src/mechanize/history.cr @@ -1,17 +1,20 @@ require "./page" -class MechanizeCr::History < Array(MechanizeCr::Page) +class MechanizeCr::History property max_size : Int32 + property array : Array(MechanizeCr::Page) + + forward_missing_to @array def initialize(max_size = 100) @max_size = max_size - super + @array = Array(MechanizeCr::Page).new end def push(page, uri = nil) - super page - while self.size > @max_size - shift + @array.push(page) + while size > @max_size + @array.shift end self end @@ -20,6 +23,6 @@ class MechanizeCr::History < Array(MechanizeCr::Page) if size == 0 # TODO: raise error end - page = super + page = @array.pop end end