Class: Kumi::Syntax::Location
- Inherits:
-
Struct
- Object
- Struct
- Kumi::Syntax::Location
- Defined in:
- lib/kumi/syntax/location.rb
Overview
The single source of truth for how a source location is rendered. Every
error message and code frame formats locations through here so the codebase
speaks one dialect: the editor-clickable file:line:col form. Do not
hand-roll "at file line=N column=M" strings elsewhere — call #to_s.
Instance Attribute Summary collapse
-
#column ⇒ Object
Returns the value of attribute column.
-
#file ⇒ Object
Returns the value of attribute file.
-
#line ⇒ Object
Returns the value of attribute line.
Instance Method Summary collapse
-
#to_s ⇒ Object
Canonical
file:line:colrendering. -
#usable? ⇒ Boolean
True when there is enough to point a user at a real spot in their source.
Instance Attribute Details
#column ⇒ Object
Returns the value of attribute column
7 8 9 |
# File 'lib/kumi/syntax/location.rb', line 7 def column @column end |
#file ⇒ Object
Returns the value of attribute file
7 8 9 |
# File 'lib/kumi/syntax/location.rb', line 7 def file @file end |
#line ⇒ Object
Returns the value of attribute line
7 8 9 |
# File 'lib/kumi/syntax/location.rb', line 7 def line @line end |
Instance Method Details
#to_s ⇒ Object
Canonical file:line:col rendering. A zero/nil column is omitted (the
column is unknown rather than column 0), giving a clean file:line.
10 11 12 13 14 |
# File 'lib/kumi/syntax/location.rb', line 10 def to_s return "#{file}:#{line}:#{column}" if column&.positive? "#{file}:#{line}" end |
#usable? ⇒ Boolean
True when there is enough to point a user at a real spot in their source.
17 18 19 |
# File 'lib/kumi/syntax/location.rb', line 17 def usable? !file.nil? && !line.nil? && line.positive? end |