Class: ERBLint::CachedOffense
- Inherits:
-
Object
- Object
- ERBLint::CachedOffense
- Defined in:
- lib/erb_lint/cached_offense.rb
Overview
A Cached version of an Offense with only essential information represented as strings
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#last_column ⇒ Object
readonly
Returns the value of attribute last_column.
-
#last_line ⇒ Object
readonly
Returns the value of attribute last_line.
-
#line_number ⇒ Object
readonly
Returns the value of attribute line_number.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
-
#simple_name ⇒ Object
readonly
Returns the value of attribute simple_name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params) ⇒ CachedOffense
constructor
A new instance of CachedOffense.
- #to_h ⇒ Object
Constructor Details
#initialize(params) ⇒ CachedOffense
Returns a new instance of CachedOffense.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/erb_lint/cached_offense.rb', line 17 def initialize(params) params = params.transform_keys(&:to_sym) @message = params[:message] @line_number = params[:line_number] @severity = params[:severity]&.to_sym @column = params[:column] @simple_name = params[:simple_name] @last_line = params[:last_line] @last_column = params[:last_column] @length = params[:length] end |
Instance Attribute Details
#column ⇒ Object (readonly)
Returns the value of attribute column.
6 7 8 |
# File 'lib/erb_lint/cached_offense.rb', line 6 def column @column end |
#last_column ⇒ Object (readonly)
Returns the value of attribute last_column.
6 7 8 |
# File 'lib/erb_lint/cached_offense.rb', line 6 def last_column @last_column end |
#last_line ⇒ Object (readonly)
Returns the value of attribute last_line.
6 7 8 |
# File 'lib/erb_lint/cached_offense.rb', line 6 def last_line @last_line end |
#line_number ⇒ Object (readonly)
Returns the value of attribute line_number.
6 7 8 |
# File 'lib/erb_lint/cached_offense.rb', line 6 def line_number @line_number end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
6 7 8 |
# File 'lib/erb_lint/cached_offense.rb', line 6 def @message end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
6 7 8 |
# File 'lib/erb_lint/cached_offense.rb', line 6 def severity @severity end |
#simple_name ⇒ Object (readonly)
Returns the value of attribute simple_name.
6 7 8 |
# File 'lib/erb_lint/cached_offense.rb', line 6 def simple_name @simple_name end |
Class Method Details
.new_from_offense(offense) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/erb_lint/cached_offense.rb', line 30 def self.new_from_offense(offense) new( { message: offense., line_number: offense.line_number, severity: offense.severity, column: offense.column, simple_name: offense.simple_name, last_line: offense.last_line, last_column: offense.last_column, length: offense.length, }, ) end |
Instance Method Details
#to_h ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/erb_lint/cached_offense.rb', line 45 def to_h { message: , line_number: line_number, severity: severity, column: column, simple_name: simple_name, last_line: last_line, last_column: last_column, length: length, } end |