Class: Opal::OpalBacktraceLocation
- Inherits:
-
Object
- Object
- Opal::OpalBacktraceLocation
- Defined in:
- 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.
52 53 54 |
# File 'lib/opal/errors.rb', line 52 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.
50 51 52 |
# File 'lib/opal/errors.rb', line 50 def label @label end |
#lineno ⇒ Object Also known as: line
Returns the value of attribute lineno.
50 51 52 |
# File 'lib/opal/errors.rb', line 50 def lineno @lineno end |
#path ⇒ Object
Returns the value of attribute path.
50 51 52 |
# File 'lib/opal/errors.rb', line 50 def path @path end |
Instance Method Details
#diagnostic=(diagnostic) ⇒ Object
70 71 72 73 |
# File 'lib/opal/errors.rb', line 70 def diagnostic=(diagnostic) return unless diagnostic self.location = diagnostic.location end |
#location=(location) ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'lib/opal/errors.rb', line 75 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
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/opal/errors.rb', line 56 def to_s string = path string += ":#{lineno}" if lineno string += ':in ' if label string += "`#{label}'" else string += 'unknown' end string end |