Class: Ferrum::Console::Location
- Inherits:
-
Object
- Object
- Ferrum::Console::Location
- Defined in:
- lib/ferrum/console/location.rb,
sig/ferrum/console/location.rbs
Overview
A place in the page's source a Message points at: where console.*
was called, an exception was thrown or a resource failed to load.
Line and column numbers are 1-based.
Instance Attribute Summary collapse
-
#column ⇒ ::Integer?
readonly
Returns the value of attribute column.
-
#function_name ⇒ String
readonly
Returns the value of attribute function_name.
-
#line ⇒ ::Integer?
readonly
Returns the value of attribute line.
-
#url ⇒ String
readonly
Returns the value of attribute url.
Class Method Summary collapse
-
.from_frame(frame) ⇒ Location
Builds a location from a CDP
Runtime.CallFrame, or from theurlandlineNumberof aLog.LogEntry.
Instance Method Summary collapse
-
#initialize(url:, line: nil, column: nil, function_name: "") ⇒ Location
constructor
A new instance of Location.
-
#to_s ⇒ String
The location as
url:line:column, leaving out what's unknown.
Constructor Details
#initialize(url:, line: nil, column: nil, function_name: "") ⇒ Location
Returns a new instance of Location.
27 28 29 30 31 32 |
# File 'lib/ferrum/console/location.rb', line 27 def initialize(url:, line: nil, column: nil, function_name: "") @url = url @line = line @column = column @function_name = function_name end |
Instance Attribute Details
#column ⇒ ::Integer? (readonly)
Returns the value of attribute column.
11 12 13 |
# File 'lib/ferrum/console/location.rb', line 11 def column @column end |
#function_name ⇒ String (readonly)
Returns the value of attribute function_name.
11 12 13 |
# File 'lib/ferrum/console/location.rb', line 11 def function_name @function_name end |
#line ⇒ ::Integer? (readonly)
Returns the value of attribute line.
11 12 13 |
# File 'lib/ferrum/console/location.rb', line 11 def line @line end |
#url ⇒ String (readonly)
Returns the value of attribute url.
11 12 13 |
# File 'lib/ferrum/console/location.rb', line 11 def url @url end |
Class Method Details
.from_frame(frame) ⇒ Location
Builds a location from a CDP Runtime.CallFrame, or from the url
and lineNumber of a Log.LogEntry. CDP numbers lines and columns
from 0.
20 21 22 23 24 25 |
# File 'lib/ferrum/console/location.rb', line 20 def self.from_frame(frame) new(url: frame["url"].to_s, line: frame["lineNumber"]&.+(1), column: frame["columnNumber"]&.+(1), function_name: frame["functionName"].to_s) end |
Instance Method Details
#to_s ⇒ String
The location as url:line:column, leaving out what's unknown.
37 38 39 |
# File 'lib/ferrum/console/location.rb', line 37 def to_s [url, line, column].compact.join(":") end |