Class: Butterfly::Provider::Twitter

Inherits:
Base
  • Object
show all
Defined in:
lib/butterfly/provider/twitter.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Butterfly::Provider::Base

Instance Method Details

#likesObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/butterfly/provider/twitter.rb', line 13

def likes
  @likes ||= raw.collect do |raw_like|
    Butterfly::Like.new({
      :service => "twitter",
      :id => raw_like["id"],
      :title => raw_like["text"],
      :description => raw_like["text"],
      :created_at => Time.parse(raw_like["created_at"]),
      :liked_at => nil,
      :tags => [],
      :photo_url => nil,
      :url => "http://twitter.com/#{raw_like["user"]["screen_name"]}/status/#{raw_like["id"]}",
      :type => "text",
      :user => Butterfly::User.new({
        :id => raw_like["user"]["id"],
        :username => raw_like["user"]["screen_name"],
        :name => raw_like["user"]["name"],
        :service_url => "http://twitter.com/#{raw_like["user"]["screen_name"]}",
        :photo_url => raw_like["user"]["profile_image_url"],
        :website_url => raw_like["user"]["url"],
        :location => raw_like["user"]["location"],
      })
    })
  end
end

#rawObject



9
10
11
# File 'lib/butterfly/provider/twitter.rb', line 9

def raw
  @raw ||= self.class.get("/favorites/#{username}.json", :format => :json, :query => { :include_entities => 1 })
end