Class: SmarterJSON::Warning

Inherits:
Struct
  • Object
show all
Defined in:
lib/smarter_json/warning.rb

Overview

A non-fatal thing the parser worked around while staying lenient — e.g. an empty comma slot it collapsed, a key with no value it read as null, or a duplicate key it dropped. Passed to the on_warning: callable (when process / process_file is given one) once per fix; otherwise the parser stays silent and builds no Warning at all.

type    — a Symbol you can branch on (:empty_slot, :empty_value, :duplicate_key)
message — human-readable description
line/col — where it happened in the input

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#colObject

Returns the value of attribute col

Returns:

  • (Object)

    the current value of col



12
13
14
# File 'lib/smarter_json/warning.rb', line 12

def col
  @col
end

#lineObject

Returns the value of attribute line

Returns:

  • (Object)

    the current value of line



12
13
14
# File 'lib/smarter_json/warning.rb', line 12

def line
  @line
end

#messageObject

Returns the value of attribute message

Returns:

  • (Object)

    the current value of message



12
13
14
# File 'lib/smarter_json/warning.rb', line 12

def message
  @message
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



12
13
14
# File 'lib/smarter_json/warning.rb', line 12

def type
  @type
end

Instance Method Details

#to_sObject



13
14
15
# File 'lib/smarter_json/warning.rb', line 13

def to_s
  line ? "#{message} at line #{line}, col #{col}" : message
end