Class: RemLint::Source

Inherits:
Struct
  • Object
show all
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

Instance Method Summary collapse

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

#descriptionObject

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



12
13
14
# File 'lib/remlint/source.rb', line 12

def description
  @description
end

#line_offsetObject

Returns the value of attribute line_offset

Returns:

  • (Object)

    the current value of line_offset



12
13
14
# File 'lib/remlint/source.rb', line 12

def line_offset
  @line_offset
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



12
13
14
# File 'lib/remlint/source.rb', line 12

def path
  @path
end

#textObject

Returns the value of attribute text

Returns:

  • (Object)

    the current value of text



12
13
14
# File 'lib/remlint/source.rb', line 12

def text
  @text
end

Instance Method Details

#labelObject

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

#linesObject



23
24
25
# File 'lib/remlint/source.rb', line 23

def lines
  text.lines
end