Class: Twitter::Tweet

Inherits:
Identity show all
Extended by:
Forwardable
Includes:
Creatable, Exceptable
Defined in:
lib/twitter/tweet.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from Creatable

#created_at

Methods inherited from Identity

#==, fetch, #id, #initialize, store

Methods inherited from Base

#[], #attr_equal, attr_reader, #attrs, #attrs_equal, fetch, fetch_or_new, from_response, identity_map, #initialize, store, #update

Constructor Details

This class inherits a constructor from Twitter::Identity

Instance Attribute Details

- (Object) favorite_count (readonly) Also known as: favorites_count, favourite_count, favourites_count, favouriters_count

Returns the value of attribute favorite_count



11
12
13
# File 'lib/twitter/tweet.rb', line 11

def favorite_count
  @favorite_count
end

- (Object) favorited (readonly) Also known as: favourited

Returns the value of attribute favorited



11
12
13
# File 'lib/twitter/tweet.rb', line 11

def favorited
  @favorited
end

- (Object) favoriters (readonly) Also known as: favouriters

Returns the value of attribute favoriters



11
12
13
# File 'lib/twitter/tweet.rb', line 11

def favoriters
  @favoriters
end

- (Object) from_user_id (readonly)

Returns the value of attribute from_user_id



11
12
13
# File 'lib/twitter/tweet.rb', line 11

def from_user_id
  @from_user_id
end

- (Object) from_user_name (readonly)

Returns the value of attribute from_user_name



11
12
13
# File 'lib/twitter/tweet.rb', line 11

def from_user_name
  @from_user_name
end

- (Object) in_reply_to_attrs_id (readonly)

Returns the value of attribute in_reply_to_attrs_id



11
12
13
# File 'lib/twitter/tweet.rb', line 11

def in_reply_to_attrs_id
  @in_reply_to_attrs_id
end

- (Object) in_reply_to_screen_name (readonly)

Returns the value of attribute in_reply_to_screen_name



11
12
13
# File 'lib/twitter/tweet.rb', line 11

def in_reply_to_screen_name
  @in_reply_to_screen_name
end

- (Object) in_reply_to_status_id (readonly) Also known as: in_reply_to_tweet_id

Returns the value of attribute in_reply_to_status_id



11
12
13
# File 'lib/twitter/tweet.rb', line 11

def in_reply_to_status_id
  @in_reply_to_status_id
end

- (Object) in_reply_to_user_id (readonly)

Returns the value of attribute in_reply_to_user_id



11
12
13
# File 'lib/twitter/tweet.rb', line 11

def in_reply_to_user_id
  @in_reply_to_user_id
end

- (Object) lang (readonly)

Returns the value of attribute lang



11
12
13
# File 'lib/twitter/tweet.rb', line 11

def lang
  @lang
end

- (Object) repliers (readonly)

Returns the value of attribute repliers



11
12
13
# File 'lib/twitter/tweet.rb', line 11

def repliers
  @repliers
end

- (Object) retweeted (readonly)

Returns the value of attribute retweeted



11
12
13
# File 'lib/twitter/tweet.rb', line 11

def retweeted
  @retweeted
end

- (Object) retweeters (readonly)

Returns the value of attribute retweeters



11
12
13
# File 'lib/twitter/tweet.rb', line 11

def retweeters
  @retweeters
end

- (Object) source (readonly)

Returns the value of attribute source



11
12
13
# File 'lib/twitter/tweet.rb', line 11

def source
  @source
end

- (Object) text (readonly)

Returns the value of attribute text



11
12
13
# File 'lib/twitter/tweet.rb', line 11

def text
  @text
end

- (Object) to_user (readonly)

Returns the value of attribute to_user



11
12
13
# File 'lib/twitter/tweet.rb', line 11

def to_user
  @to_user
end

- (Object) to_user_id (readonly)

Returns the value of attribute to_user_id



11
12
13
# File 'lib/twitter/tweet.rb', line 11

def to_user_id
  @to_user_id
end

- (Object) to_user_name (readonly)

Returns the value of attribute to_user_name



11
12
13
# File 'lib/twitter/tweet.rb', line 11

def to_user_name
  @to_user_name
end

- (Object) truncated (readonly)

Returns the value of attribute truncated



11
12
13
# File 'lib/twitter/tweet.rb', line 11

def truncated
  @truncated
end

Instance Method Details

- (Boolean) entities?

Returns:

  • (Boolean)


27
28
29
# File 'lib/twitter/tweet.rb', line 27

def entities?
  !@attrs[:entities].nil?
end

- (Integer) favoriters_count

Returns:

  • (Integer)


32
33
34
35
# File 'lib/twitter/tweet.rb', line 32

def favoriters_count
  favoriters_count = @attrs[:favoriters_count]
  favoriters_count.to_i if favoriters_count
end

- (Object) filter_level



42
43
44
# File 'lib/twitter/tweet.rb', line 42

def filter_level
  @attrs[:filter_level] || "none"
end

- (String) from_user

Returns:

  • (String)


38
39
40
# File 'lib/twitter/tweet.rb', line 38

def from_user
  @attrs[:from_user] || user && user.screen_name
end

- (String) full_text

Note:

May be > 140 characters.

Returns:

  • (String)


48
49
50
51
52
53
54
55
# File 'lib/twitter/tweet.rb', line 48

def full_text
  if retweeted_status
    prefix = text[/\A(RT @[a-z0-9_]{1,20}: )/i, 1]
    [prefix, retweeted_status.text].compact.join
  else
    text
  end
end

- (Twitter::Geo) geo

Returns:



58
59
60
# File 'lib/twitter/tweet.rb', line 58

def geo
  @geo ||= Twitter::GeoFactory.fetch_or_new(@attrs[:geo])
end

- (Array<Twitter::Entity::Hashtag>) hashtags

Note:

Must include entities in your request for this method to work

Returns:



64
65
66
# File 'lib/twitter/tweet.rb', line 64

def hashtags
  @hashtags ||= entities(Twitter::Entity::Hashtag, :hashtags)
end

- (Array<Twitter::Media>) media

Note:

Must include entities in your request for this method to work

Returns:



70
71
72
# File 'lib/twitter/tweet.rb', line 70

def media
  @media ||= entities(Twitter::MediaFactory, :media)
end

- (Twitter::Metadata) metadata

Returns:



75
76
77
# File 'lib/twitter/tweet.rb', line 75

def 
  @metadata ||= Twitter::Metadata.fetch_or_new(@attrs[:metadata])
end

- (Twitter::Place) place

Returns:



80
81
82
# File 'lib/twitter/tweet.rb', line 80

def place
  @place ||= Twitter::Place.fetch_or_new(@attrs[:place])
end

- (Integer) repliers_count Also known as: reply_count

Returns:

  • (Integer)


85
86
87
88
# File 'lib/twitter/tweet.rb', line 85

def repliers_count
  repliers_count = @attrs[:repliers_count]
  repliers_count.to_i if repliers_count
end

- (Boolean) reply?

Returns:

  • (Boolean)


92
93
94
# File 'lib/twitter/tweet.rb', line 92

def reply?
  !!in_reply_to_status_id
end

- (Boolean) retweet?

Returns:

  • (Boolean)


97
98
99
# File 'lib/twitter/tweet.rb', line 97

def retweet?
  !!retweeted_status
end

- (Twitter::Tweet) retweeted_status Also known as: retweeted_tweet, retweet

If this Tweet is a retweet, the original Tweet is available here.

Returns:



104
105
106
# File 'lib/twitter/tweet.rb', line 104

def retweeted_status
  @retweeted_status ||= self.class.fetch_or_new(@attrs[:retweeted_status])
end

- (String) retweeters_count Also known as: retweet_count

Returns:

  • (String)


111
112
113
114
# File 'lib/twitter/tweet.rb', line 111

def retweeters_count
  retweeters_count = (@attrs[:retweet_count] || @attrs[:retweeters_count])
  retweeters_count.to_i if retweeters_count
end

- (Array<Twitter::Entity::Url>) urls

Note:

Must include entities in your request for this method to work

Returns:



119
120
121
# File 'lib/twitter/tweet.rb', line 119

def urls
  @urls ||= entities(Twitter::Entity::Url, :urls)
end

- (Twitter::User) user

Returns:



124
125
126
# File 'lib/twitter/tweet.rb', line 124

def user
  @user ||= fetch_or_new_without_self(Twitter::User, @attrs, :user, :status)
end

- (Boolean) user?

Returns:

  • (Boolean)


134
135
136
# File 'lib/twitter/tweet.rb', line 134

def user?
  !@attrs[:user].nil?
end

- (Array<Twitter::Entity::UserMention>) user_mentions

Note:

Must include entities in your request for this method to work

Returns:



130
131
132
# File 'lib/twitter/tweet.rb', line 130

def user_mentions
  @user_mentions ||= entities(Twitter::Entity::UserMention, :user_mentions)
end