class TimeMath::HashResampler
@private
Public Class Methods
new(unit, hash)
click to toggle source
Calls superclass method
TimeMath::Resampler::new
# File lib/time_math/resamplers.rb, line 62 def initialize(unit, hash) super(unit) @hash = hash end
try(unit, hash)
click to toggle source
# File lib/time_math/resamplers.rb, line 56 def self.try(unit, hash) return unless hash.is_a?(Hash) && hash.keys.all?(&Util.method(:timey?)) new(unit, hash) end
Public Instance Methods
call(symbol = nil, &block)
click to toggle source
# File lib/time_math/resamplers.rb, line 67 def call(symbol = nil, &block) block = symbol.to_proc if symbol && !block sequence.ranges.map do |r| values = @hash.select { |k, _| r.cover?(k) }.map(&:last) values = block.call(values) if block [r.begin, values] end.to_h end
Private Instance Methods
timestamps()
click to toggle source
# File lib/time_math/resamplers.rb, line 79 def timestamps @hash.keys end