Class: Jade::Diagnostics::List
- Inherits:
-
Data
- Object
- Data
- Jade::Diagnostics::List
- Defined in:
- lib/jade/diagnostics.rb
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
Class Method Summary collapse
Instance Method Summary collapse
- #add(diagnostic) ⇒ Object
- #any_errors? ⇒ Boolean
- #empty? ⇒ Boolean
- #error(message, source:, span:, label: nil, secondary: [], annotations: []) ⇒ Object
- #help(text) ⇒ Object
- #merge(other) ⇒ Object
- #note(text) ⇒ Object
- #to_result(value) ⇒ Object
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items
26 27 28 |
# File 'lib/jade/diagnostics.rb', line 26 def items @items end |
Class Method Details
.empty ⇒ Object
27 28 29 |
# File 'lib/jade/diagnostics.rb', line 27 def self.empty new(items: []) end |
Instance Method Details
#add(diagnostic) ⇒ Object
31 32 33 |
# File 'lib/jade/diagnostics.rb', line 31 def add(diagnostic) with(items: items + [diagnostic]) end |
#any_errors? ⇒ Boolean
56 57 58 |
# File 'lib/jade/diagnostics.rb', line 56 def any_errors? items.any?(&:error?) end |
#empty? ⇒ Boolean
60 61 62 |
# File 'lib/jade/diagnostics.rb', line 60 def empty? items.empty? end |
#error(message, source:, span:, label: nil, secondary: [], annotations: []) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/jade/diagnostics.rb', line 35 def error(, source:, span:, label: nil, secondary: [], annotations: []) add(Diagnostic.error( , primary: Label[source, span, label], secondary:, annotations:, )) end |
#help(text) ⇒ Object
48 49 50 |
# File 'lib/jade/diagnostics.rb', line 48 def help(text) update_last { _1.annotate(:help, text) } end |
#merge(other) ⇒ Object
52 53 54 |
# File 'lib/jade/diagnostics.rb', line 52 def merge(other) with(items: items + other.items) end |
#note(text) ⇒ Object
44 45 46 |
# File 'lib/jade/diagnostics.rb', line 44 def note(text) update_last { _1.annotate(:note, text) } end |