Method: Twterm::Status#initialize

Defined in:
lib/twterm/status.rb

#initialize(tweet) ⇒ Status

Returns a new instance of Status.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/twterm/status.rb', line 16

def initialize(tweet)
  unless tweet.retweeted_status.is_a? Twitter::NullObject
    @retweeted_by_user_id = tweet.user.id
    User.create(tweet.user)
    retweeted_at = Status.parse_time(tweet.created_at)
    tweet = tweet.retweeted_status
  end

  @id = tweet.id
  @text = CGI.unescapeHTML(tweet.full_text.dup)
  @created_at = Status.parse_time(tweet.created_at)
  @created_at_for_sort = retweeted_at || @created_at
  @retweet_count = tweet.retweet_count
  @favorite_count = tweet.favorite_count
  @in_reply_to_status_id = tweet.in_reply_to_status_id

  @retweeted = tweet.retweeted?
  @favorited = tweet.favorited?

  @media = tweet.media
  @urls = tweet.urls

  @user_id = tweet.user.id
  User.create(tweet.user)

  @splitted_text = {}

  expand_url!

  @touched_at = Time.now

  tweet.hashtags.each do |hashtag|
    History::Hashtag.instance.add(hashtag.text)
  end

  @@instances[id] = self
end