Class: ImproveYourCode::SmellWarning
- Inherits:
-
Object
- Object
- ImproveYourCode::SmellWarning
- Extended by:
- Forwardable
- Includes:
- Comparable
- Defined in:
- lib/improve_your_code/smell_warning.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#smell_detector ⇒ Object
readonly
Returns the value of attribute smell_detector.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #base_message ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(smell_detector, context: '', lines:, message:, source:, parameters: {}) ⇒ SmellWarning
constructor
A new instance of SmellWarning.
- #smell_class ⇒ Object
- #to_hash ⇒ Object (also: #yaml_hash)
Constructor Details
#initialize(smell_detector, context: '', lines:, message:, source:, parameters: {}) ⇒ SmellWarning
Returns a new instance of SmellWarning.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/improve_your_code/smell_warning.rb', line 13 def initialize(smell_detector, context: '', lines:, message:, source:, parameters: {}) @smell_detector = smell_detector @source = source @context = context.to_s @lines = lines @message = @parameters = parameters freeze end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
10 11 12 |
# File 'lib/improve_your_code/smell_warning.rb', line 10 def context @context end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
10 11 12 |
# File 'lib/improve_your_code/smell_warning.rb', line 10 def lines @lines end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
10 11 12 |
# File 'lib/improve_your_code/smell_warning.rb', line 10 def @message end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
10 11 12 |
# File 'lib/improve_your_code/smell_warning.rb', line 10 def parameters @parameters end |
#smell_detector ⇒ Object (readonly)
Returns the value of attribute smell_detector.
10 11 12 |
# File 'lib/improve_your_code/smell_warning.rb', line 10 def smell_detector @smell_detector end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
10 11 12 |
# File 'lib/improve_your_code/smell_warning.rb', line 10 def source @source end |
Instance Method Details
#<=>(other) ⇒ Object
29 30 31 |
# File 'lib/improve_your_code/smell_warning.rb', line 29 def <=>(other) <=> other. end |
#base_message ⇒ Object
44 45 46 |
# File 'lib/improve_your_code/smell_warning.rb', line 44 def "#{smell_type}: #{context} #{}" end |
#eql?(other) ⇒ Boolean
33 34 35 |
# File 'lib/improve_your_code/smell_warning.rb', line 33 def eql?(other) (self <=> other).zero? end |
#hash ⇒ Object
25 26 27 |
# File 'lib/improve_your_code/smell_warning.rb', line 25 def hash .hash end |
#smell_class ⇒ Object
48 49 50 |
# File 'lib/improve_your_code/smell_warning.rb', line 48 def smell_class smell_detector.class end |
#to_hash ⇒ Object Also known as: yaml_hash
37 38 39 40 |
# File 'lib/improve_your_code/smell_warning.rb', line 37 def to_hash stringified_params = Hash[parameters.map { |key, val| [key.to_s, val] }] base_hash.merge(stringified_params) end |