Class: MarkdownComposer::Diagnostics
- Inherits:
-
Object
- Object
- MarkdownComposer::Diagnostics
- Defined in:
- lib/markdown_composer/diagnostics.rb
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
Instance Method Summary collapse
- #any_errors? ⇒ Boolean
- #as_json ⇒ Object
- #concat(other) ⇒ Object
- #error(code, message, path: nil, details: nil) ⇒ Object
- #errors ⇒ Object
- #info(code, message, path: nil, details: nil) ⇒ Object
-
#initialize(items = []) ⇒ Diagnostics
constructor
A new instance of Diagnostics.
- #to_a ⇒ Object
- #warn(code, message, path: nil, details: nil) ⇒ Object
Constructor Details
#initialize(items = []) ⇒ Diagnostics
Returns a new instance of Diagnostics.
19 20 21 |
# File 'lib/markdown_composer/diagnostics.rb', line 19 def initialize(items = []) @items = items end |
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
17 18 19 |
# File 'lib/markdown_composer/diagnostics.rb', line 17 def items @items end |
Instance Method Details
#any_errors? ⇒ Boolean
44 45 46 |
# File 'lib/markdown_composer/diagnostics.rb', line 44 def any_errors? errors.any? end |
#as_json ⇒ Object
52 53 54 |
# File 'lib/markdown_composer/diagnostics.rb', line 52 def as_json @items.map(&:to_h) end |
#concat(other) ⇒ Object
35 36 37 38 |
# File 'lib/markdown_composer/diagnostics.rb', line 35 def concat(other) @items.concat(other.to_a) self end |
#error(code, message, path: nil, details: nil) ⇒ Object
31 32 33 |
# File 'lib/markdown_composer/diagnostics.rb', line 31 def error(code, , path: nil, details: nil) add(:error, code, , path: path, details: details) end |
#errors ⇒ Object
40 41 42 |
# File 'lib/markdown_composer/diagnostics.rb', line 40 def errors @items.select { |item| item.severity == :error } end |
#info(code, message, path: nil, details: nil) ⇒ Object
23 24 25 |
# File 'lib/markdown_composer/diagnostics.rb', line 23 def info(code, , path: nil, details: nil) add(:info, code, , path: path, details: details) end |
#to_a ⇒ Object
48 49 50 |
# File 'lib/markdown_composer/diagnostics.rb', line 48 def to_a @items end |
#warn(code, message, path: nil, details: nil) ⇒ Object
27 28 29 |
# File 'lib/markdown_composer/diagnostics.rb', line 27 def warn(code, , path: nil, details: nil) add(:warning, code, , path: path, details: details) end |