class TimeMath::Resampler

@private

Public Class Methods

call(unit, array_or_hash, symbol = nil, &block) click to toggle source
# File lib/time_math/resamplers.rb, line 5
def call(unit, array_or_hash, symbol = nil, &block)
  resampler =
    ArrayResampler.try(unit, array_or_hash) ||
    HashResampler.try(unit, array_or_hash) or
    raise ArgumentError, "Expected array of timestamps or hash with timestamp keys, #{array_or_hash} got"

  resampler.call(symbol, &block)
end
new(unit) click to toggle source
# File lib/time_math/resamplers.rb, line 15
def initialize(unit)
  @unit = Units.get(unit)
end

Public Instance Methods

call() click to toggle source
# File lib/time_math/resamplers.rb, line 19
def call
  raise NotImplementedError
end

Private Instance Methods

sequence() click to toggle source
# File lib/time_math/resamplers.rb, line 25
def sequence
  @sequence ||= @unit.sequence(timestamps.min..timestamps.max)
end