def offset_from_frequency frequency
        return frequency if frequency.is_a?(Daru::DateOffset)
        frequency ||= 'D'

        matched = FREQUENCY_PATTERN.match(frequency) or
          raise ArgumentError, "Invalid frequency string #{frequency}"

        n             = (matched[:multiplier] || 1).to_i
        offset_string = matched[:offset]
        offset_klass  = OFFSETS_HASH[offset_string] or
          raise ArgumentError, "Cannont interpret offset #{offset_string}"

        if offset_string == 'W'
          offset_klass.new(n, weekday: Daru::DAYS_OF_WEEK[matched[:weekday]])
        else
          offset_klass.new(n)
        end
      end
Generates a Daru::DateOffset object for generic offsets or one of the
specialized classed within Daru::Offsets depending on the 'frequency'
string.