帮酷LOGO
0 0 评论
文章标签:命令行  COM  显示  DOC    Comma  COMM  

要从命令行显示ruby rdoc文档,只需使用ri命令,如下所示:

ri String

这个简单的命令将显示ruby String类的rdoc文档,

ri String

还有这个:

ri String

例子字符串输出

下面是键入ri String命令的例子输出:

---------------------------------------------------------- 
Class: String
 A +String+ object holds and manipulates an arbitrary sequence of
 bytes, typically representing characters. String objects may be
 created using +String::new+ or as literals.
 Because of aliasing issues, users of strings should be aware of the
 methods that modify the contents of a +String+ object. Typically,
 methods with names ending in ``!'' modify their receiver, while
 those without a ``!'' return a new +String+. However, there are
 exceptions, such as +String#[]=+.
------------------------------------------------------------------------
 Enhance the String class with a XML escaped character version of
 to_s.
------------------------------------------------------------------------
 User defined methods to be added to String.
------------------------------------------------------------------------
Includes:
---------
 Comparable(<, <=, ==, >, >=, between?), Enumerable(all?, any?,
 collect, detect, each_cons, each_slice, each_with_index, entries,
 enum_cons, enum_slice, enum_with_index, find, find_all, grep,
 group_by, include?, index_by, inject, map, max, member?, min,
 partition, reject, select, sort, sort_by, sum, to_a, to_set, zip)
(more ...)

Bonus coverage:irb (交互式ruby shell )

在命令行中,如果你想从命令行运行简单ruby命令,只需启动irb,交互式ruby shell,如下所示:

irb

运行该命令后,irb将按以下的方式提示你:

>>

此时,你可以键入所需的ruby命令,如下所示:

a = 1 + 2

键入命令后,irb将显示与该命令相关的输出,如下所示:

=> 3


文章标签:COM  COMM  DOC    Comma  命令行  显示  

Copyright © 2011 HelpLib All rights reserved.    知识分享协议 京ICP备05059198号-3  |  如果智培  |  酷兔英语