Module: Twitter::Entities
- Includes:
- Memoizable
- Included in:
- DirectMessage, DirectMessageEvent, DirectMessages::WelcomeMessage, Tweet
- Defined in:
- lib/twitter/entities.rb
Overview
Provides methods for accessing entities in tweets
Instance Method Summary collapse
-
#entities? ⇒ Boolean
Returns true if the object has any entities.
-
#hashtags ⇒ Array<Twitter::Entity::Hashtag>
Returns an array of hashtags in the object.
-
#hashtags? ⇒ Boolean
Returns true if the object has any hashtags.
-
#media ⇒ Array<Twitter::Media>
Returns an array of media in the object.
-
#media? ⇒ Boolean
Returns true if the object has any media.
-
#symbols ⇒ Array<Twitter::Entity::Symbol>
Returns an array of symbols in the object.
-
#symbols? ⇒ Boolean
Returns true if the object has any symbols.
-
#uris ⇒ Array<Twitter::Entity::URI>
(also: #urls)
Returns an array of URIs in the object.
-
#uris? ⇒ Boolean
(also: #urls?)
Returns true if the object has any URIs.
-
#user_mentions ⇒ Array<Twitter::Entity::UserMention>
Returns an array of user mentions in the object.
-
#user_mentions? ⇒ Boolean
Returns true if the object has any user mentions.
Instance Method Details
#entities? ⇒ Boolean
Returns true if the object has any entities
19 20 21 |
# File 'lib/twitter/entities.rb', line 19 def entities? !@attrs[:entities].nil? && @attrs[:entities].any? { |_, array| array.any? } # steep:ignore FallbackAny end |
#hashtags ⇒ Array<Twitter::Entity::Hashtag>
Must include entities in your request for this method to work
Returns an array of hashtags in the object
31 32 33 |
# File 'lib/twitter/entities.rb', line 31 def entities(Entity::Hashtag, :hashtags) end |
#hashtags? ⇒ Boolean
Returns true if the object has any hashtags
42 43 44 |
# File 'lib/twitter/entities.rb', line 42 def .any? end |
#media ⇒ Array<Twitter::Media>
Must include entities in your request for this method to work
Returns an array of media in the object
54 55 56 57 |
# File 'lib/twitter/entities.rb', line 54 def media extended_entities = entities(MediaFactory, :media, :extended_entities) extended_entities.empty? ? entities(MediaFactory, :media) : extended_entities end |
#media? ⇒ Boolean
Returns true if the object has any media
66 67 68 |
# File 'lib/twitter/entities.rb', line 66 def media? media.any? end |
#symbols ⇒ Array<Twitter::Entity::Symbol>
Must include entities in your request for this method to work
Returns an array of symbols in the object
78 79 80 |
# File 'lib/twitter/entities.rb', line 78 def symbols entities(Entity::Symbol, :symbols) end |
#symbols? ⇒ Boolean
Returns true if the object has any symbols
89 90 91 |
# File 'lib/twitter/entities.rb', line 89 def symbols? symbols.any? end |
#uris ⇒ Array<Twitter::Entity::URI> Also known as: urls
Must include entities in your request for this method to work
Returns an array of URIs in the object
101 102 103 |
# File 'lib/twitter/entities.rb', line 101 def uris entities(Entity::URI, :urls) end |
#uris? ⇒ Boolean Also known as: urls?
Returns true if the object has any URIs
120 121 122 |
# File 'lib/twitter/entities.rb', line 120 def uris? uris.any? end |
#user_mentions ⇒ Array<Twitter::Entity::UserMention>
Must include entities in your request for this method to work
Returns an array of user mentions in the object
139 140 141 |
# File 'lib/twitter/entities.rb', line 139 def user_mentions entities(Entity::UserMention, :user_mentions) end |
#user_mentions? ⇒ Boolean
Returns true if the object has any user mentions
150 151 152 |
# File 'lib/twitter/entities.rb', line 150 def user_mentions? user_mentions.any? end |