Class: Opal::OpalBacktraceLocation
- Inherits:
-
Object
- Object
- Opal::OpalBacktraceLocation
- Defined in:
- opal/lib/opal/errors.rb
Overview
Loosely compatible with Thread::Backtrace::Location
Instance Attribute Summary collapse
-
#label ⇒ Object
Returns the value of attribute label.
-
#lineno ⇒ Object
(also: #line)
Returns the value of attribute lineno.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #diagnostic=(diagnostic) ⇒ Object
-
#initialize(path = nil, lineno = nil, label = nil) ⇒ OpalBacktraceLocation
constructor
A new instance of OpalBacktraceLocation.
- #location=(location) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(path = nil, lineno = nil, label = nil) ⇒ OpalBacktraceLocation
Returns a new instance of OpalBacktraceLocation.
55 56 57 |
# File 'opal/lib/opal/errors.rb', line 55 def initialize(path = nil, lineno = nil, label = nil) @path, @lineno, @label = path, lineno, label end |
Instance Attribute Details
#label ⇒ Object
Returns the value of attribute label.
53 54 55 |
# File 'opal/lib/opal/errors.rb', line 53 def label @label end |
#lineno ⇒ Object Also known as: line
Returns the value of attribute lineno.
53 54 55 |
# File 'opal/lib/opal/errors.rb', line 53 def lineno @lineno end |
#path ⇒ Object
Returns the value of attribute path.
53 54 55 |
# File 'opal/lib/opal/errors.rb', line 53 def path @path end |
Instance Method Details
#diagnostic=(diagnostic) ⇒ Object
73 74 75 76 |
# File 'opal/lib/opal/errors.rb', line 73 def diagnostic=(diagnostic) return unless diagnostic self.location = diagnostic.location end |
#location=(location) ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'opal/lib/opal/errors.rb', line 78 def location=(location) return unless location self.lineno = location.line if location.respond_to?(:source_line) self.label = location.source_line elsif location.respond_to?(:expression) self.label = location.expression.source_line end end |
#to_s ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'opal/lib/opal/errors.rb', line 59 def to_s string = path string += ":#{lineno}" if lineno string += ':in ' if label string += "`#{label}'" else string += 'unknown' end string end |