Exception: MightyJSON::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/mighty_json/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, type:, value:) ⇒ Error

Returns a new instance of Error.



5
6
7
8
9
# File 'lib/mighty_json/errors.rb', line 5

def initialize(path:, type:, value:)
  @path = path
  @type = type
  @value = value
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/mighty_json/errors.rb', line 3

def path
  @path
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/mighty_json/errors.rb', line 3

def type
  @type
end

#valueObject (readonly)

Returns the value of attribute value.



3
4
5
# File 'lib/mighty_json/errors.rb', line 3

def value
  @value
end

Instance Method Details

#to_sObject Also known as: message



11
12
13
14
# File 'lib/mighty_json/errors.rb', line 11

def to_s
  position = path.empty? ? "" : " at .#{path.join('.')}"
  "Expected type of value #{value}#{position} is #{type}"
end