Exception: Converty::CantConvertError

Inherits:
Error
  • Object
show all
Defined in:
lib/converty.rb

Overview

Error thrown when trying to convert between two different types of units, e.g. distance to weight.

Instance Method Summary collapse

Constructor Details

#initialize(from, to) ⇒ CantConvertError

Returns a new instance of CantConvertError.



12
13
14
15
16
17
# File 'lib/converty.rb', line 12

def initialize(from, to)
  from_unit = UNITS.fetch(from)
  to_unit = UNITS.fetch(to)
  message = "can't convert #{from_unit.fetch(:type)} (#{from}) to #{to_unit.fetch(:type)} (#{to})"
  super(message)
end