Time.advance 记录在哪里? [英] Where is Time.advance documented?

查看:35
本文介绍了Time.advance 记录在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

环顾网络,我发现 Ruby Time 类具有 Time#advance.这是在哪里记录的?我在 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.

API 文档的搜索功能表明在任何地方都没有名为advance"的方法.

The search function for the API docs indicated that there is no method called "advance" anywhere.

尽管如此,在 IRB 中...

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

另一件让我感到困惑的事情...在 time 类的文档中,它说的第一件事是实现 time.rb 库文档中描述的 Time 类的扩展."

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."

他们的意思是time.rb 库实现了这个类的扩展?"

Do they mean "the time.rb library implements extensions to this class?"

我想也许这就是 Time#advance 的来源,但我发现的只是 这个.

I thought maybe that's where Time#advance came from but all I found was this.

推荐答案

其实在ActiveSupport::CoreExtensions::Numeric::Time 模块.

It's actually in the ActiveSupport::CoreExtensions::Numeric::Time module.

这是我对 Ruby 的抱怨之一 - 不可能为对象具有的每个方法找到全面的文档,因为方法列表会根据上下文而变化.强大,但令人恼火.

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.

我正在开发一个不是我最初编写的大型 Rails 应用程序,有一次我在谷歌上搜索了一个几分钟后我不认识的方法,然后才意识到……是的,以前的开发人员在/lib.

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.

这篇关于Time.advance 记录在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆