Looking around on the Web I found that the Ruby Time
class has Time#advance
. Where is this documented? I saw no mention of it in the Ruby API docs here.
The search function for the API docs indicated that there is no method called "advance" anywhere.
Nonetheless, in IRB...
>> t = Time.now
=> Thu Mar 05 16:08:57 -0800 2009
>> t.advance :months => 1
=> Sun Apr 05 16:08:57 -0700 2009
Another thing that puzzles me... In the docs for the time class, the first thing it says is "Implements the extensions to the Time class that are described in the documentation for the time.rb library."
Do they mean "the time.rb library implements extensions to this class?"
I thought maybe that's where Time#advance came from but all I found was this.
It's actually in the ActiveSupport::CoreExtensions::Numeric::Time
module.
This is one of my gripes with Ruby - it's impossible to find comprehensive documentation for every method an object has, because the method list changes depending on the context. Powerful, yet irritating.
I'm working on a large Rails app that I did not write originally, and once in a while I google a method I don't recognize for a few minutes before realizing...yep, the previous developer defined it in /lib.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With