Class: Tweet

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/twitter/cli/models/tweet.rb

Class Method Summary collapse

Class Method Details

.create_from_tweet(account, s) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/twitter/cli/models/tweet.rb', line 4

def self.create_from_tweet(, s)
  tweet             = .tweets.find_or_initialize_by_twitter_id(s.id)
  tweet.body        = s.text
  tweet.occurred_at = s.created_at
  
  %w[truncated favorited in_reply_to_status_id in_reply_to_user_id source].each do |m|
    tweet.send("#{m}=", s.send(m))
  end
  
  %w[id followers_count name screen_name location description 
    profile_image_url url protected].each do |m|
    tweet.send("user_#{m}=", s.user.send(m))
  end
  tweet.save!
  tweet
end