timerizer
timerizer copied to clipboard
Implement to_f
Nice to see another gem that's trying to break free from Rails dependencies. Thanks for the effort!
A number of other libraries run to_f on durations (e.g. Sidekiq). When I tried it with timerizer, it threw:
NoMethodError: undefined method `to_f' for #<Timerizer::Duration:0x00007f25c88d79e0 @seconds=60, @months=0>
It'd be a huge help in terms of compatibilty if .to_f worked for duration.
Timerizer isn't really meant to be a drop-in replacement for Rails' time syntax, but this seems low-cost and clear enough that it's probably still worth doing. Since Timerizer doesn't support sub-second units, would something like this be sufficient?
class Duration
# ...
def to_f
self.to_i.to_f
end
end
Yeah, I think that'd work.