add history comment
parent
f1fbaf6668
commit
b3c4c46616
|
@ -1,6 +1,10 @@
|
||||||
require "./page"
|
require "./page"
|
||||||
|
|
||||||
|
# This class represents the history of http response you sent.
|
||||||
|
# If you send a request, mechanize saves the history.
|
||||||
class MechanizeCr::History
|
class MechanizeCr::History
|
||||||
|
# max page size history can save. default is 100.
|
||||||
|
# as same as `agent.max_history`.
|
||||||
property max_size : Int32
|
property max_size : Int32
|
||||||
property array : Array(MechanizeCr::Page)
|
property array : Array(MechanizeCr::Page)
|
||||||
|
|
||||||
|
@ -11,6 +15,7 @@ class MechanizeCr::History
|
||||||
@array = array
|
@array = array
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# add page to history.
|
||||||
def push(page, uri = nil)
|
def push(page, uri = nil)
|
||||||
@array.push(page)
|
@array.push(page)
|
||||||
while size > @max_size
|
while size > @max_size
|
||||||
|
@ -19,6 +24,7 @@ class MechanizeCr::History
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# take the last page out from history.
|
||||||
def pop
|
def pop
|
||||||
if size == 0
|
if size == 0
|
||||||
# TODO: raise error
|
# TODO: raise error
|
||||||
|
|
Loading…
Reference in New Issue