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

#favoritedObject (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

#favoritersObject (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

#from_user_idObject (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

#from_user_nameObject (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

#in_reply_to_attrs_idObject (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

#in_reply_to_screen_nameObject (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

#in_reply_to_status_idObject (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

#in_reply_to_user_idObject (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

#iso_language_codeObject (readonly)

Returns the value of attribute iso_language_code.



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

def iso_language_code
  @iso_language_code
end

#repliersObject (readonly)

Returns the value of attribute repliers.



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

def repliers
  @repliers
end

#retweetedObject (readonly)

Returns the value of attribute retweeted.



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

def retweeted
  @retweeted
end

#retweetersObject (readonly)

Returns the value of attribute retweeters.



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

def retweeters
  @retweeters
end

#sourceObject (readonly)

Returns the value of attribute source.



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

def source
  @source
end

#textObject (readonly)

Returns the value of attribute text.



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

def text
  @text
end

#to_userObject (readonly)

Returns the value of attribute to_user.



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

def to_user
  @to_user
end

#to_user_idObject (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

#to_user_nameObject (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

#truncatedObject (readonly)

Returns the value of attribute truncated.



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

def truncated
  @truncated
end

Instance Method Details

#entities?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/twitter/tweet.rb', line 23

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

#favoriters_countInteger Also known as: favorite_count, favorites_count, favourite_count, favourites_count, favouriters_count

Returns:

  • (Integer)


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

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

#from_userString

Returns:

  • (String)


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

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

#full_textString

Note:

May be > 140 characters.

Returns:

  • (String)


45
46
47
48
49
50
51
52
# File 'lib/twitter/tweet.rb', line 45

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

#geoTwitter::Geo

Returns:



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

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

Returns:



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

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:



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

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

#metadataTwitter::Metadata

Returns:



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

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

#placeTwitter::Place

Returns:



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

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

#repliers_countInteger Also known as: reply_count

Returns:

  • (Integer)


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

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

#reply?Boolean

Returns:

  • (Boolean)


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

def reply?
  !!in_reply_to_status_id
end

#retweet?Boolean

Returns:

  • (Boolean)


94
95
96
# File 'lib/twitter/tweet.rb', line 94

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:



101
102
103
# File 'lib/twitter/tweet.rb', line 101

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

#retweeters_countString Also known as: retweet_count

Returns:

  • (String)


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

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

Returns:



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

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

#userTwitter::User

Returns:



121
122
123
# File 'lib/twitter/tweet.rb', line 121

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

#user?Boolean

Returns:

  • (Boolean)


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

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

#user_mentionsArray<Twitter::Entity::UserMention>

Note:

Must include entities in your request for this method to work

Returns:



127
128
129
# File 'lib/twitter/tweet.rb', line 127

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