Method: Twterm::Status#initialize

Defined in:
lib/twterm/status.rb

#initialize(tweet) ⇒ Status

Returns a new instance of Status.



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/twterm/status.rb', line 51

def initialize(tweet)
  unless tweet.retweeted_status.is_a? Twitter::NullObject
    @retweeted_by_user_id = tweet.user.id
    User.new(tweet.user)
    retweeted_at = tweet.created_at.dup.localtime
    tweet = tweet.retweeted_status
  end

  @id = tweet.id
  @text = CGI.unescapeHTML(tweet.full_text.dup)
  @created_at = tweet.created_at.dup.localtime
  @appeared_at = 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.new(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