Class: Twitter::Tweet

Inherits:
Identity show all
Includes:
Creatable
Defined in:
lib/twitter/tweet.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#attrs

Instance Method Summary collapse

Methods included from Creatable

#created_at

Methods inherited from Identity

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

Methods inherited from Base

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

Constructor Details

This class inherits a constructor from Twitter::Identity

Instance Attribute Details

#favoritedObject (readonly) Also known as: favorited?, favourited, favourited?

Returns the value of attribute favorited.



16
17
18
# File 'lib/twitter/tweet.rb', line 16

def favorited
  @favorited
end

#favoritersObject (readonly)

Returns the value of attribute favoriters.



16
17
18
# File 'lib/twitter/tweet.rb', line 16

def favoriters
  @favoriters
end

#from_user_idObject (readonly)

Returns the value of attribute from_user_id.



16
17
18
# File 'lib/twitter/tweet.rb', line 16

def from_user_id
  @from_user_id
end

#from_user_nameObject (readonly)

Returns the value of attribute from_user_name.



16
17
18
# File 'lib/twitter/tweet.rb', line 16

def from_user_name
  @from_user_name
end

#in_reply_to_attrs_idObject (readonly)

Returns the value of attribute in_reply_to_attrs_id.



16
17
18
# File 'lib/twitter/tweet.rb', line 16

def in_reply_to_attrs_id
  @in_reply_to_attrs_id
end

#in_reply_to_screen_nameObject (readonly)

Returns the value of attribute in_reply_to_screen_name.



16
17
18
# File 'lib/twitter/tweet.rb', line 16

def in_reply_to_screen_name
  @in_reply_to_screen_name
end

#in_reply_to_status_idObject (readonly) Also known as: in_reply_to_tweet_id

Returns the value of attribute in_reply_to_status_id.



16
17
18
# File 'lib/twitter/tweet.rb', line 16

def in_reply_to_status_id
  @in_reply_to_status_id
end

#in_reply_to_user_idObject (readonly)

Returns the value of attribute in_reply_to_user_id.



16
17
18
# File 'lib/twitter/tweet.rb', line 16

def in_reply_to_user_id
  @in_reply_to_user_id
end

#iso_language_codeObject (readonly)

Returns the value of attribute iso_language_code.



16
17
18
# File 'lib/twitter/tweet.rb', line 16

def iso_language_code
  @iso_language_code
end

#profile_image_urlObject (readonly)

Returns the value of attribute profile_image_url.



16
17
18
# File 'lib/twitter/tweet.rb', line 16

def profile_image_url
  @profile_image_url
end

#profile_image_url_httpsObject (readonly)

Returns the value of attribute profile_image_url_https.



16
17
18
# File 'lib/twitter/tweet.rb', line 16

def profile_image_url_https
  @profile_image_url_https
end

#repliersObject (readonly)

Returns the value of attribute repliers.



16
17
18
# File 'lib/twitter/tweet.rb', line 16

def repliers
  @repliers
end

#retweetedObject (readonly) Also known as: retweeted?

Returns the value of attribute retweeted.



16
17
18
# File 'lib/twitter/tweet.rb', line 16

def retweeted
  @retweeted
end

#retweetersObject (readonly)

Returns the value of attribute retweeters.



16
17
18
# File 'lib/twitter/tweet.rb', line 16

def retweeters
  @retweeters
end

#sourceObject (readonly)

Returns the value of attribute source.



16
17
18
# File 'lib/twitter/tweet.rb', line 16

def source
  @source
end

#textObject (readonly)

Returns the value of attribute text.



16
17
18
# File 'lib/twitter/tweet.rb', line 16

def text
  @text
end

#to_userObject (readonly)

Returns the value of attribute to_user.



16
17
18
# File 'lib/twitter/tweet.rb', line 16

def to_user
  @to_user
end

#to_user_idObject (readonly)

Returns the value of attribute to_user_id.



16
17
18
# File 'lib/twitter/tweet.rb', line 16

def to_user_id
  @to_user_id
end

#to_user_nameObject (readonly)

Returns the value of attribute to_user_name.



16
17
18
# File 'lib/twitter/tweet.rb', line 16

def to_user_name
  @to_user_name
end

#truncatedObject (readonly) Also known as: truncated?

Returns the value of attribute truncated.



16
17
18
# File 'lib/twitter/tweet.rb', line 16

def truncated
  @truncated
end

Instance Method Details

#entities?Boolean

Returns:

  • (Boolean)


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

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

#favoriters_countInteger Also known as: favorite_count, favourite_count, favouriters_count

Returns:

  • (Integer)


29
30
31
32
# File 'lib/twitter/tweet.rb', line 29

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

#from_userString

Returns:



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

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

#full_textString

Note:

May be > 140 characters.

Returns:



44
45
46
# File 'lib/twitter/tweet.rb', line 44

def full_text
  retweeted_status && retweeted_status.user ? "RT @#{retweeted_status.user.screen_name}: #{retweeted_status.text}" : text
end

#geoTwitter::Geo

Returns:



49
50
51
# File 'lib/twitter/tweet.rb', line 49

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

#hashtagsArray<Twitter::Entity::Hashtag>

Note:

Must include entities in your request for this method to work



55
56
57
# File 'lib/twitter/tweet.rb', line 55

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

#mediaArray<Twitter::Media>

Note:

Must include entities in your request for this method to work

Returns:



61
62
63
# File 'lib/twitter/tweet.rb', line 61

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

#metadataTwitter::Metadata

Returns:



66
67
68
# File 'lib/twitter/tweet.rb', line 66

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

#placeTwitter::Place

Returns:



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

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

#repliers_countInteger Also known as: reply_count

Returns:

  • (Integer)


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

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

#retweet?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/twitter/tweet.rb', line 82

def retweet?
  !!retweeted_status
end

#retweeted_statusTwitter::Tweet Also known as: retweeted_tweet, retweet

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

Returns:



89
90
91
# File 'lib/twitter/tweet.rb', line 89

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

#retweeters_countString Also known as: retweet_count

Returns:



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

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

#urlsArray<Twitter::Entity::Url>

Note:

Must include entities in your request for this method to work



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

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

#userTwitter::User

Returns:



109
110
111
# File 'lib/twitter/tweet.rb', line 109

def user
  @user ||= Twitter::User.fetch_or_new(@attrs.dup[:user].merge(:status => @attrs.except(:user))) if user?
end

#user_mentionsArray<Twitter::Entity::UserMention>

Note:

Must include entities in your request for this method to work



115
116
117
# File 'lib/twitter/tweet.rb', line 115

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