我在哪里可以找到Prime类文档

时间:2011-10-04 06:53:09

标签: ruby documentation

如果我像这样使用Prime类:

Prime.new

我会收到下一条消息:

Prime::new is obsolete. use Prime::instance or class methods of Prime.

tryied finding这个类文档,但不能。

2 个答案:

答案 0 :(得分:4)

不幸的是,似乎尚未在ruby-doc.org上发布。但你现在可以看看at the commented source code;它包括用法示例。

答案 1 :(得分:2)

您应该通过ri

在本地使用它
$ ri Prime

= Prime < Object

------------------------------------------------------------------------------
= Includes:
Enumerable (from ruby core)

(from ruby core)
------------------------------------------------------------------------------
The set of all prime numbers.

== Example
     Prime.each(100) do |prime|
       p prime  #=> 2, 3, 5, 7, 11, ...., 97
     end

== Retrieving the instance
Prime.new is obsolete. Now Prime has the default instance and you can access
it as Prime.instance.
...

还有RubyDoc.info,它有更好的索引:

  

http://rubydoc.info/stdlib/prime/1.9.2/frames