Class: QuietQuality::Message
- Inherits:
-
Object
- Object
- QuietQuality::Message
- Defined in:
- lib/quiet_quality/message.rb
Constant Summary collapse
- REQUIRED_ATTRS =
%w[path body start_line tool_name].freeze
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
- #body ⇒ Object
-
#initialize(**attrs) ⇒ Message
constructor
A new instance of Message.
- #level ⇒ Object
- #path ⇒ Object
- #rule ⇒ Object
- #start_line ⇒ Object
- #stop_line ⇒ Object
- #to_h ⇒ Object
- #tool_name ⇒ Object
Constructor Details
#initialize(**attrs) ⇒ Message
Returns a new instance of Message.
11 12 13 14 |
# File 'lib/quiet_quality/message.rb', line 11 def initialize(**attrs) @attrs = attrs.map { |k, v| [k.to_s, v] }.to_h validate_attrs! end |
Instance Attribute Details
#annotated_line ⇒ Object
40 41 42 |
# File 'lib/quiet_quality/message.rb', line 40 def annotated_line @annotated_line ||= @attrs.fetch("annotated_line", nil) end |
Class Method Details
.load(hash) ⇒ Object
7 8 9 |
# File 'lib/quiet_quality/message.rb', line 7 def self.load(hash) new(**hash) end |
Instance Method Details
#body ⇒ Object
24 25 26 |
# File 'lib/quiet_quality/message.rb', line 24 def body @_body ||= @attrs.fetch("body") end |
#level ⇒ Object
44 45 46 |
# File 'lib/quiet_quality/message.rb', line 44 def level @_level ||= @attrs.fetch("level", nil) end |
#path ⇒ Object
20 21 22 |
# File 'lib/quiet_quality/message.rb', line 20 def path @_path ||= @attrs.fetch("path") end |
#rule ⇒ Object
48 49 50 |
# File 'lib/quiet_quality/message.rb', line 48 def rule @_rule ||= @attrs.fetch("rule", nil) end |
#start_line ⇒ Object
32 33 34 |
# File 'lib/quiet_quality/message.rb', line 32 def start_line @_start_line ||= @attrs.fetch("start_line") end |
#stop_line ⇒ Object
36 37 38 |
# File 'lib/quiet_quality/message.rb', line 36 def stop_line @_stop_line ||= @attrs.fetch("stop_line", start_line) end |
#to_h ⇒ Object
16 17 18 |
# File 'lib/quiet_quality/message.rb', line 16 def to_h @attrs.map { |k, v| [k.to_s, v] }.to_h end |
#tool_name ⇒ Object
28 29 30 |
# File 'lib/quiet_quality/message.rb', line 28 def tool_name @_tool_name ||= @attrs.fetch("tool_name") end |