Class: JSON5::Diagnostic
- Inherits:
-
Object
- Object
- JSON5::Diagnostic
- Defined in:
- lib/json5/diagnostic.rb
Instance Attribute Summary collapse
-
#byte_offset ⇒ Object
readonly
Returns the value of attribute byte_offset.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#end_byte_offset ⇒ Object
readonly
Returns the value of attribute end_byte_offset.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
Instance Method Summary collapse
-
#initialize(code:, message:, severity: :warning, filename: nil, byte_offset: nil, end_byte_offset: nil, line: nil, column: nil) ⇒ Diagnostic
constructor
A new instance of Diagnostic.
- #to_h ⇒ Object
Constructor Details
#initialize(code:, message:, severity: :warning, filename: nil, byte_offset: nil, end_byte_offset: nil, line: nil, column: nil) ⇒ Diagnostic
Returns a new instance of Diagnostic.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/json5/diagnostic.rb', line 8 def initialize(code:, message:, severity: :warning, filename: nil, byte_offset: nil, end_byte_offset: nil, line: nil, column: nil) @severity = severity.to_sym @code = code.to_s.dup.freeze @message = .to_s.dup.freeze @filename = filename.nil? ? nil : filename.to_s.dup.freeze @byte_offset = byte_offset @end_byte_offset = end_byte_offset @line = line @column = column freeze end |
Instance Attribute Details
#byte_offset ⇒ Object (readonly)
Returns the value of attribute byte_offset.
5 6 7 |
# File 'lib/json5/diagnostic.rb', line 5 def byte_offset @byte_offset end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
5 6 7 |
# File 'lib/json5/diagnostic.rb', line 5 def code @code end |
#column ⇒ Object (readonly)
Returns the value of attribute column.
5 6 7 |
# File 'lib/json5/diagnostic.rb', line 5 def column @column end |
#end_byte_offset ⇒ Object (readonly)
Returns the value of attribute end_byte_offset.
5 6 7 |
# File 'lib/json5/diagnostic.rb', line 5 def end_byte_offset @end_byte_offset end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
5 6 7 |
# File 'lib/json5/diagnostic.rb', line 5 def filename @filename end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
5 6 7 |
# File 'lib/json5/diagnostic.rb', line 5 def line @line end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
5 6 7 |
# File 'lib/json5/diagnostic.rb', line 5 def @message end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
5 6 7 |
# File 'lib/json5/diagnostic.rb', line 5 def severity @severity end |
Instance Method Details
#to_h ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/json5/diagnostic.rb', line 22 def to_h { severity: severity, code: code, message: , filename: filename, byte_offset: byte_offset, end_byte_offset: end_byte_offset, line: line, column: column } end |