【发布时间】:2015-05-15 02:34:24
【问题描述】:
我正在使用 twitter gem 在 ruby 中流式传输推文。 我的代码是
client.filter(:track => topics.join(",")) do |object|
if(object.is_a?(Twitter::Entities))
puts object.text if object.is_a?(Twitter::Tweet)
puts object.created_at
puts object.hashtags.to_s
puts object.user.name
end
end
我需要获取推文中的 hashtags,如果我使用上面的代码,我得到的输出是
[#<Twitter::Entity::Hashtag:0x007ff23a06d4c8 @attrs={:text=>"coffee", :indices=>[20, 27]}>, #<Twitter::Entity::Hashtag:0x007ff23a06d450 @attrs={:text=>"mornings", :indices=>[28, 37]}>, #<Twitter::Entity::Hashtag:0x007ff23a06d428 @attrs={:text=>"cantstopmoving", :indices=>[38, 53]}>]
有没有办法获取单个主题标签
【问题讨论】: