Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is Time.advance documented?

Tags:

time

ruby

api

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.

like image 542
Ethan Avatar asked Mar 06 '09 00:03

Ethan


1 Answers

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.

like image 73
Sarah Mei Avatar answered Sep 30 '22 12:09

Sarah Mei