Class: Slamdown::Diagnostic
- Inherits:
-
Object
- Object
- Slamdown::Diagnostic
- Defined in:
- lib/slamdown/diagnostic.rb
Overview
Describes one construction or conversion observation without exposing mutable internal state.
Constant Summary collapse
- SEVERITIES =
[:info, :warning, :error].freeze
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#node_path ⇒ Object
readonly
Returns the value of attribute node_path.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
Instance Method Summary collapse
-
#initialize(code:, severity:, message:, node_path: nil) ⇒ Diagnostic
constructor
A new instance of Diagnostic.
Constructor Details
#initialize(code:, severity:, message:, node_path: nil) ⇒ Diagnostic
Returns a new instance of Diagnostic.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/slamdown/diagnostic.rb', line 11 def initialize(code:, severity:, message:, node_path: nil) raise ArgumentError, "diagnostic code must be a Symbol" unless code.is_a?(Symbol) raise ArgumentError, "invalid diagnostic severity: #{severity.inspect}" unless SEVERITIES.include?(severity) raise ArgumentError, "diagnostic message must be a String" unless .is_a?(String) raise ArgumentError, "diagnostic node_path must contain only non-negative integers" unless valid_node_path?(node_path) @code = code @severity = severity @message = .dup.freeze @node_path = node_path && node_path.dup.freeze freeze end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
9 10 11 |
# File 'lib/slamdown/diagnostic.rb', line 9 def code @code end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
9 10 11 |
# File 'lib/slamdown/diagnostic.rb', line 9 def @message end |
#node_path ⇒ Object (readonly)
Returns the value of attribute node_path.
9 10 11 |
# File 'lib/slamdown/diagnostic.rb', line 9 def node_path @node_path end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
9 10 11 |
# File 'lib/slamdown/diagnostic.rb', line 9 def severity @severity end |