Exception: MightyJSON::Type::Error

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Error.



229
230
231
232
233
# File 'lib/mighty_json/type.rb', line 229

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

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



227
228
229
# File 'lib/mighty_json/type.rb', line 227

def path
  @path
end

#typeObject (readonly)

Returns the value of attribute type.



227
228
229
# File 'lib/mighty_json/type.rb', line 227

def type
  @type
end

#valueObject (readonly)

Returns the value of attribute value.



227
228
229
# File 'lib/mighty_json/type.rb', line 227

def value
  @value
end

Instance Method Details

#to_sObject



235
236
237
238
# File 'lib/mighty_json/type.rb', line 235

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