我正在使用twitter创业板在红宝石中流推文。我的代码是
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我需要在tweet中获取哈希标签,如果我使用上面的代码,我将得到如下输出
[#<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]}>]有没有一种方法来获取单个的散列标签?
发布于 2015-03-13 06:45:05
object.hashtags.each do |p|
puts "HashTags " +p.text.to_s
endhttps://stackoverflow.com/questions/29018207
复制相似问题