Class: Lumin::Offense
- Inherits:
-
Object
- Object
- Lumin::Offense
- Defined in:
- lib/lumin/offense.rb
Instance Attribute Summary collapse
-
#correction ⇒ Object
readonly
Returns the value of attribute correction.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#rule_name ⇒ Object
readonly
Returns the value of attribute rule_name.
-
#safe ⇒ Object
readonly
Returns the value of attribute safe.
-
#source_line ⇒ Object
readonly
Returns the value of attribute source_line.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #correctable? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(path:, location:, rule_name:, message:, correctable: false, safe: true, source_line: nil, correction: nil) ⇒ Offense
constructor
A new instance of Offense.
- #marshal_dump ⇒ Object
- #marshal_load(attributes) ⇒ Object
- #to_h ⇒ Object
- #with_path(path) ⇒ Object
Constructor Details
#initialize(path:, location:, rule_name:, message:, correctable: false, safe: true, source_line: nil, correction: nil) ⇒ Offense
Returns a new instance of Offense.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/lumin/offense.rb', line 9 def initialize(path:, location:, rule_name:, message:, correctable: false, safe: true, source_line: nil, correction: nil) @path = path.to_s.freeze @location = Astel::Location.from(location) @rule_name = rule_name.to_s.freeze @message = .to_s.freeze @correctable = correctable @safe = safe @source_line = source_line&.freeze @correction = correction end |
Instance Attribute Details
#correction ⇒ Object (readonly)
Returns the value of attribute correction.
7 8 9 |
# File 'lib/lumin/offense.rb', line 7 def correction @correction end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
7 8 9 |
# File 'lib/lumin/offense.rb', line 7 def location @location end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
7 8 9 |
# File 'lib/lumin/offense.rb', line 7 def @message end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/lumin/offense.rb', line 7 def path @path end |
#rule_name ⇒ Object (readonly)
Returns the value of attribute rule_name.
7 8 9 |
# File 'lib/lumin/offense.rb', line 7 def rule_name @rule_name end |
#safe ⇒ Object (readonly)
Returns the value of attribute safe.
7 8 9 |
# File 'lib/lumin/offense.rb', line 7 def safe @safe end |
#source_line ⇒ Object (readonly)
Returns the value of attribute source_line.
7 8 9 |
# File 'lib/lumin/offense.rb', line 7 def source_line @source_line end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
41 42 43 |
# File 'lib/lumin/offense.rb', line 41 def ==(other) other.is_a?(self.class) && to_h == other.to_h end |
#correctable? ⇒ Boolean
21 22 23 |
# File 'lib/lumin/offense.rb', line 21 def correctable? @correctable end |
#hash ⇒ Object
46 47 48 |
# File 'lib/lumin/offense.rb', line 46 def hash to_h.hash end |
#marshal_dump ⇒ Object
50 51 52 |
# File 'lib/lumin/offense.rb', line 50 def marshal_dump to_h end |
#marshal_load(attributes) ⇒ Object
54 55 56 |
# File 'lib/lumin/offense.rb', line 54 def marshal_load(attributes) initialize(**attributes) end |
#to_h ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/lumin/offense.rb', line 29 def to_h { path: path, location: location, rule_name: rule_name, message: , correctable: correctable?, safe: safe, source_line: source_line } end |
#with_path(path) ⇒ Object
25 26 27 |
# File 'lib/lumin/offense.rb', line 25 def with_path(path) self.class.new(**to_h.merge(path: path)) end |