Method: ConvertUnit::Volume#to

Defined in:
lib/convert_unit/volume.rb

#to(c_unit) ⇒ Object

Raises:

  • (ArgumentError)


19
20
21
22
23
24
# File 'lib/convert_unit/volume.rb', line 19

def to(c_unit)
  c_unit.downcase!
  unit_symbol = Volume::UNITS_SYMBOL[c_unit] || c_unit
  raise ArgumentError, 'Impossible conversion type' unless Volume::UNITS.include?(unit_symbol)
  Volume.new(convert_to(unit_symbol), unit_symbol)
end