def to_unit(unit)
      unit_details = self.class.resolve_unit(unit)

      if unit_details.has_key?(:seconds)
        seconds = self.normalize.get(:seconds)
        self.class.div(seconds, unit_details.fetch(:seconds))
      elsif unit_details.has_key?(:months)
        months = self.denormalize.get(:months)
        self.class.div(months, unit_details.fetch(:months))
      else
        raise "Unit should have key :seconds or :months"
      end
    end
def to_unit(unit)
      unit_details = self.class.resolve_unit(unit)

      if unit_details.has_key?(:seconds)
        seconds = self.normalize.get(:seconds)
        self.class.div(seconds, unit_details.fetch(:seconds))
      elsif unit_details.has_key?(:months)
        months = self.denormalize.get(:months)
        self.class.div(months, unit_details.fetch(:months))
      else
        raise "Unit should have key :seconds or :months"
      end
    end
Convert the duration to a given unit.

 @param [Symbol] unit The unit to convert to. See {UNIT_ALIASES} for a list
   of valid unit names.

 @return [Integer] The quantity of the given unit present in `self`. Note
   that, if `self` cannot be represented exactly by `unit`, then the result
   will be truncated (rounded toward 0 instead of rounding down, unlike
   normal Ruby integer division).

 @raise ArgumentError if the given unit could not be resolved.

 @example
   1.hour.to_unit(:minutes)
   # => 60
   121.seconds.to_unit(:minutes)
   # => 2

 @note The duration is normalized or denormalized first, depending on the
   unit requested. This means that, by default, the returned unit will
   be an approximation if it cannot be represented exactly by the duration,
   such as when converting a duration of months to seconds, or vice versa.

 @see #to_units