Class: Playwright::JavaScript::VisitorInfo
- Inherits:
-
Object
- Object
- Playwright::JavaScript::VisitorInfo
- Defined in:
- lib/playwright/javascript/visitor_info.rb
Instance Method Summary collapse
-
#initialize ⇒ VisitorInfo
constructor
A new instance of VisitorInfo.
- #log(object) ⇒ Object
-
#ref(object) ⇒ Object
returns [Integer|nil].
Constructor Details
#initialize ⇒ VisitorInfo
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 |