Class: Playwright::JavaScript::VisitorInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/playwright/javascript/visitor_info.rb

Instance Method Summary collapse

Constructor Details

#initializeVisitorInfo

Returns a new instance of VisitorInfo.



4
5
6
7
# File 'lib/playwright/javascript/visitor_info.rb', line 4

def initialize
  @data = {}
  @last_id = 0
end

Instance Method Details

#log(object) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/playwright/javascript/visitor_info.rb', line 14

def log(object)
  if @data[object]
    raise ArgumentError.new("Already visited")
  end

  id = @last_id + 1
  @last_id = id # FIXME: should thread-safe

  @data[object] = id
end

#ref(object) ⇒ Object

returns [Integer|nil]



10
11
12
# File 'lib/playwright/javascript/visitor_info.rb', line 10

def ref(object)
  @data[object]
end