Class: Twitter::Status
- Inherits:
-
Base
- Object
- Base
- Twitter::Status
- Includes:
- Creatable
- Defined in:
- lib/twitter/status.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary (collapse)
- - (Boolean) ==(other)
- - (Array<String>) expanded_urls
- - (String) from_user
- - (String) full_text
- - (Twitter::Point, Twitter::Polygon) geo
- - (Array<Twitter::Entity::Hashtag>) hashtags
- - (Array) media
- - (Twitter::Metadata) metadata
- - (Twitter::OEmbed) oembed(options = {})
- - (Twitter::Place) place
-
- (Twitter::Status) retweeted_status
If this status is itself a retweet, the original tweet is available here.
- - (Array<Twitter::Entity::Url>) urls
- - (Twitter::User) user
- - (Array<Twitter::Entity::UserMention>) user_mentions
Methods included from Creatable
Methods inherited from Base
#[], #initialize, lazy_attr_reader
Constructor Details
This class inherits a constructor from Twitter::Base
Instance Method Details
- (Boolean) ==(other)
30 31 32 |
# File 'lib/twitter/status.rb', line 30 def ==(other) super || (other.class == self.class && other.id == self.id) end |
- (Array<String>) expanded_urls
Note:
Must include entities in your request for this method to work
36 37 38 39 |
# File 'lib/twitter/status.rb', line 36 def warn "#{Kernel.caller.first}: [DEPRECATION] Twitter::Status#expanded_urls it deprecated. Use Twitter::Status#urls instead." urls.map(&:expanded_url) unless urls.nil? end |
- (String) from_user
42 43 44 |
# File 'lib/twitter/status.rb', line 42 def from_user @attrs['from_user'] || self.user && self.user.screen_name end |
- (String) full_text
Note:
May be > 140 characters.
48 49 50 |
# File 'lib/twitter/status.rb', line 48 def full_text self.retweeted_status && self.retweeted_status.user ? "RT @#{self.retweeted_status.user.screen_name}: #{self.retweeted_status.text}" : self.text end |
- (Twitter::Point, Twitter::Polygon) geo
53 54 55 |
# File 'lib/twitter/status.rb', line 53 def geo @geo ||= Twitter::GeoFactory.new(@attrs['geo']) unless @attrs['geo'].nil? end |
- (Array<Twitter::Entity::Hashtag>) hashtags
Note:
Must include entities in your request for this method to work
59 60 61 62 63 64 65 66 67 |
# File 'lib/twitter/status.rb', line 59 def @hashtags ||= unless @attrs['entities'].nil? Array(@attrs['entities']['hashtags']).map do |hashtag| Twitter::Entity::Hashtag.new(hashtag) end else warn "#{Kernel.caller.first}: To get hashtags, you must pass `:include_entities => true` when requesting the Twitter::Status." end end |
- (Array) media
Note:
Must include entities in your request for this method to work
71 72 73 74 75 76 77 78 79 |
# File 'lib/twitter/status.rb', line 71 def media @media ||= unless @attrs['entities'].nil? Array(@attrs['entities']['media']).map do |media| Twitter::MediaFactory.new(media) end else warn "#{Kernel.caller.first}: To get media, you must pass `:include_entities => true` when requesting the Twitter::Status." end end |
- (Twitter::Metadata) metadata
82 83 84 |
# File 'lib/twitter/status.rb', line 82 def @metadata ||= Twitter::Metadata.new(@attrs['metadata']) unless @attrs['metadata'].nil? end |
- (Twitter::OEmbed) oembed(options = {})
87 88 89 90 |
# File 'lib/twitter/status.rb', line 87 def (={}) @client ||= Twitter::Client.new @client.(@attrs['id'], ) unless @attrs['id'].nil? end |
- (Twitter::Place) place
93 94 95 |
# File 'lib/twitter/status.rb', line 93 def place @place ||= Twitter::Place.new(@attrs['place']) unless @attrs['place'].nil? end |
- (Twitter::Status) retweeted_status
If this status is itself a retweet, the original tweet is available here.
100 101 102 |
# File 'lib/twitter/status.rb', line 100 def retweeted_status @retweeted_status ||= self.class.new(@attrs['retweeted_status']) unless @attrs['retweeted_status'].nil? end |
- (Array<Twitter::Entity::Url>) urls
Note:
Must include entities in your request for this method to work
106 107 108 109 110 111 112 113 114 |
# File 'lib/twitter/status.rb', line 106 def urls @urls ||= unless @attrs['entities'].nil? Array(@attrs['entities']['urls']).map do |url| Twitter::Entity::Url.new(url) end else warn "#{Kernel.caller.first}: To get URLs, you must pass `:include_entities => true` when requesting the Twitter::Status." end end |
- (Twitter::User) user
117 118 119 |
# File 'lib/twitter/status.rb', line 117 def user @user ||= Twitter::User.new(@attrs.dup['user'].merge('status' => @attrs.except('user'))) unless @attrs['user'].nil? end |
- (Array<Twitter::Entity::UserMention>) user_mentions
Note:
Must include entities in your request for this method to work
123 124 125 126 127 128 129 130 131 |
# File 'lib/twitter/status.rb', line 123 def user_mentions @user_mentions ||= unless @attrs['entities'].nil? Array(@attrs['entities']['user_mentions']).map do |user_mention| Twitter::Entity::UserMention.new(user_mention) end else warn "#{Kernel.caller.first}: To get user mentions, you must pass `:include_entities => true` when requesting the Twitter::Status." end end |