开发者

Ruby RSS -- Private method send called for RSS:REXMLListener

I am trying to integrate a RSS parser into my IRC bot, and i've found some simple code to do so online, however, if i put this code in the bot, I get this:

Error: private method `send' called for #<RSS::REXMLListener:0x3d7c790>

I'm not sure why it gives me this error, as it works fine in IRB or in its own private script. This is the code, and the line thats causing the error.

def fetch_rss_items(url, max_items = nil)
    %w{open-uri rss/0.9 rss/1.0 rss/2.0 rss/parser}.each do |lib|
        require(lib)
    end

    rss = RSS::Parser.pa开发者_JS百科rse(open(url).read) #This line is causing the error
    rss.items[0...(max_items ? max_items : rss.items.length)]
end


I'm pretty sure, that I just had the same issue:

private method send' called for #<Nokogiri::CSS::XPathVisitor:0x31b6108>; c:/ruby192/lib/ruby/gems/1.9.1/gems/nokogiri-1.4.3.1-x86-mingw32/lib/nokogiri/css/node.rb:17:inaccept'

The problem is that somewhere you have declared function send, and: ruby's default namespace is the Object class, and methods you define in the default namespace are considered private methods of Object

http://railsforum.com/viewtopic.php?id=31016

P.S.: anyone knows how to avoid such bugs?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜