Dashing的Ruby文件有问题 [英] Having problems with Ruby file from Dashing

查看:98
本文介绍了Dashing的Ruby文件有问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 twitter_user.rb 上遇到麻烦,应该可以获取给定Twitter用户名的推文,关注者和关注者的数量。

I am having trouble with twitter_user.rb, which is supposed to get the number of tweets, followers, and following of a given Twitter username.

我假设我应该替换 TWITTER_USERNAME 在第9行中输入了我感兴趣的Twitter用户名。我这样做并开始破折号,但我得到了:

I assume that I am supposed to replace TWITTER_USERNAME in line 9 with the Twitter username that I am interested in. I did that and started dashing but I got:

scheduler caught exception:
undefined method '[]' for nil:NilClass
/.../jobs/twitter_user.rb:19:in 'block in <top (required)>'

看起来问题出在第19行:

It looks like the problem is with line 19 which is:

tweets = /profile["']>[\n\t\s]*<strong>([\d.,]+)/.match(response.body)[1].delete('.,').to_i

有人可以告诉我怎么回事以及如何解决它吗?

Can anybody tell me what is going on and how to fix it?

推荐答案

您的假设是错误的。程序正在寻找名为 TWITTER_USERNAME 环境变量,该变量设置为相关的用户名。如果该变量不存在,则代码使用 foobugs 代替。

Your assumption is incorrect. The program is looking for an environment variable called TWITTER_USERNAME that is set to the relevant user name. If that variable doesn't exist then the code uses foobugs instead.

如果您想修改代码而不是设置环境变量,然后更改

If you would rather modify the code than set up an environment variable, then change

twitter_username = ENV['TWITTER_USERNAME'] || 'foobugs'

twitter_username = 'myusername'

这篇关于Dashing的Ruby文件有问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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