Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement to_f #11

Open
greggilbert opened this issue Sep 20, 2019 · 2 comments
Open

Implement to_f #11

greggilbert opened this issue Sep 20, 2019 · 2 comments

Comments

@greggilbert
Copy link

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.

@kylewlacy
Copy link
Owner

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

@greggilbert
Copy link
Author

Yeah, I think that'd work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants