Class: RemLint::Source
- Inherits:
-
Struct
- Object
- Struct
- RemLint::Source
- Defined in:
- lib/remlint/source.rb
Overview
A run of Remind code carved out of a file, together with where it sat.
line_offset is the number of physical lines that preceded this run in the
file on disk -- zero for a plain .rem file, and the line number of the
heredoc's opener for Remind embedded in a shell script. Every line number
the linter reports is computed through this offset, so an offence inside
the third heredoc of a shell script points at the real line of that script
rather than at line 4 of an anonymous fragment.
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#line_offset ⇒ Object
Returns the value of attribute line_offset.
-
#path ⇒ Object
Returns the value of attribute path.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(path:, text:, line_offset: 0, description: nil) ⇒ Source
constructor
A new instance of Source.
-
#label ⇒ Object
How to name this source in a message when a file yields more than one.
- #lines ⇒ Object
Constructor Details
#initialize(path:, text:, line_offset: 0, description: nil) ⇒ Source
Returns a new instance of Source.
19 20 21 |
# File 'lib/remlint/source.rb', line 19 def initialize(path:, text:, line_offset: 0, description: nil) super end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description
12 13 14 |
# File 'lib/remlint/source.rb', line 12 def description @description end |
#line_offset ⇒ Object
Returns the value of attribute line_offset
12 13 14 |
# File 'lib/remlint/source.rb', line 12 def line_offset @line_offset end |
#path ⇒ Object
Returns the value of attribute path
12 13 14 |
# File 'lib/remlint/source.rb', line 12 def path @path end |
#text ⇒ Object
Returns the value of attribute text
12 13 14 |
# File 'lib/remlint/source.rb', line 12 def text @text end |
Instance Method Details
#label ⇒ Object
How to name this source in a message when a file yields more than one.
28 29 30 31 32 33 34 |
# File 'lib/remlint/source.rb', line 28 def label if description "#{path} (#{description})" else path end end |
#lines ⇒ Object
23 24 25 |
# File 'lib/remlint/source.rb', line 23 def lines text.lines end |