add max_history

This commit is contained in:
Kanezoh 2021-08-09 19:30:11 +09:00
parent 900d5a419a
commit d9eaef74bd
3 changed files with 21 additions and 1 deletions

View File

@ -101,4 +101,14 @@ class Mechanize
def add_to_history(page)
history.push(page)
end
# Get maximum number of items allowed in the history. The default setting is 100 pages.
def max_history
history.max_size
end
# Set maximum number of items allowed in the history.
def max_history=(length)
history.max_size = length
end
end

View File

@ -1,7 +1,7 @@
require "./page"
class MechanizeCr::History < Array(MechanizeCr::Page)
property :max_size
property max_size : Int32
def initialize(max_size = 100)
@max_size = max_size
super

View File

@ -53,6 +53,16 @@ module MechanizeCr
@history.pop
end
# Get maximum number of items allowed in the history. The default setting is 100 pages.
def max_history
@history.max_size
end
# Set maximum number of items allowed in the history.
def max_history=(length)
@history.max_size = length
end
private def set_request_headers(uri, headers)
reset_request_header_cookies
headers.each do |k,v|