作者热门文章
- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我现在正在记录一些 ruby 代码。我们有两个类都有一个名为“host”的方法。
在其中一个类中,该方法需要一些特殊注释。在另一个类中,我想引用第一个类,并将该引用作为指向它的链接。
通常在 rdoc 中,键入一个方法的名称就足以生成一个链接。在这种情况下,即使我写出 Class::SubClass.host
链接仍然坚持指向当前类中的方法。
有哪位 rdoc 高手知道如何做到这一点?
这是 FakeTown::Api
中的一个例子,我想链接到 RealTown::Api
的方法 #host
:
# Returns the host as defined in config.yml under the heading "url".
#
# It appears as though this method is no longer in use, as
# features/support/vcr_config.rb contains its own method
# by the same name which directly references RealTown::Api#url
def host
uri = URI.parse url
uri.host
end
rdoc 生成的链接毫无帮助地直接链接回本文档中的 #host
方法。
谢谢!
最佳答案
您可能想链接到实例方法,而不是类方法。 Class::SubClass#host
应该可以工作。
下面的例子就是你所描述的。
class A
# first method
def a
end
end
class B
# second method linking to A#a
def a
end
end
关于ruby - 链接到不同类中的同名方法 (Rdoc),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6365047/
我正在开发一个 voip 调用应用程序。我需要做的是在接到来电时将 Activity 带到前台。我在应用程序中使用 Twilio,并在收到推送消息时开始调用。 问题是我试图在接到任何电话时显示 Act
我是一名优秀的程序员,十分优秀!