Class: Twitter::User
- Defined in:
- lib/twitter/user.rb
Overview
Represents a Twitter user
Constant Summary
Constants included from Profile
Profile::PROFILE_IMAGE_SUFFIX_REGEX
Instance Attribute Summary collapse
-
#connections ⇒ Array
readonly
The user’s connections.
-
#description ⇒ String
readonly
The user’s time zone.
-
#email ⇒ String
readonly
The user’s time zone.
-
#favourites_count ⇒ Integer
(also: #favorites_count)
readonly
The UTC offset in seconds.
-
#followers_count ⇒ Integer
readonly
The UTC offset in seconds.
-
#friends_count ⇒ Integer
readonly
The UTC offset in seconds.
-
#lang ⇒ String
readonly
The user’s time zone.
-
#listed_count ⇒ Integer
readonly
The UTC offset in seconds.
-
#location ⇒ String
readonly
The user’s time zone.
-
#name ⇒ String
readonly
The user’s time zone.
-
#profile_background_color ⇒ String
readonly
The user’s time zone.
-
#profile_link_color ⇒ String
readonly
The user’s time zone.
-
#profile_sidebar_border_color ⇒ String
readonly
The user’s time zone.
-
#profile_sidebar_fill_color ⇒ String
readonly
The user’s time zone.
-
#profile_text_color ⇒ String
readonly
The user’s time zone.
-
#statuses_count ⇒ Integer
(also: #tweets_count)
readonly
The UTC offset in seconds.
-
#time_zone ⇒ String
readonly
The user’s time zone.
-
#utc_offset ⇒ Integer
readonly
The UTC offset in seconds.
Attributes inherited from BasicUser
Attributes inherited from Identity
Attributes inherited from Base
Instance Method Summary collapse
-
#description_uris ⇒ Array<Twitter::Entity::URI>
(also: #description_urls)
Returns an array of URIs in the user’s description.
-
#description_uris? ⇒ Boolean
(also: #description_urls?)
Returns true if the user has description URIs.
-
#entities? ⇒ Boolean
Returns true if the user has entities.
-
#uri ⇒ URI::Generic
(also: #url)
Returns the URI to the user’s profile.
-
#website ⇒ URI::Generic
Returns the user’s website URL.
-
#website? ⇒ Boolean
Returns true if the user has a website.
-
#website_uris ⇒ Array<Twitter::Entity::URI>
(also: #website_urls)
Returns an array of URIs in the user’s website.
-
#website_uris? ⇒ Boolean
(also: #website_urls?)
Returns true if the user has website URIs.
Methods included from Profile
#profile_banner_uri, #profile_banner_uri?, #profile_banner_uri_https, #profile_image_uri, #profile_image_uri?, #profile_image_uri_https
Methods included from Creatable
Methods inherited from Identity
Methods inherited from Base
#[], attr_reader, define_attribute_method, define_predicate_method, define_uri_method, display_uri_attr_reader, #initialize, object_attr_reader, predicate_attr_reader, uri_attr_reader
Methods included from Utils
Constructor Details
This class inherits a constructor from Twitter::Identity
Instance Attribute Details
#connections ⇒ Array (readonly)
The user’s connections
19 20 21 |
# File 'lib/twitter/user.rb', line 19 def connections @connections end |
#description ⇒ String (readonly)
The user’s time zone
141 142 143 |
# File 'lib/twitter/user.rb', line 141 def description @description end |
#email ⇒ String (readonly)
The user’s time zone
141 142 143 |
# File 'lib/twitter/user.rb', line 141 def email @email end |
#favourites_count ⇒ Integer (readonly) Also known as: favorites_count
The UTC offset in seconds
62 63 64 |
# File 'lib/twitter/user.rb', line 62 def favourites_count @favourites_count end |
#followers_count ⇒ Integer (readonly)
The UTC offset in seconds
62 63 64 |
# File 'lib/twitter/user.rb', line 62 def followers_count @followers_count end |
#friends_count ⇒ Integer (readonly)
The UTC offset in seconds
62 63 64 |
# File 'lib/twitter/user.rb', line 62 def friends_count @friends_count end |
#lang ⇒ String (readonly)
The user’s time zone
141 142 143 |
# File 'lib/twitter/user.rb', line 141 def lang @lang end |
#listed_count ⇒ Integer (readonly)
The UTC offset in seconds
62 63 64 |
# File 'lib/twitter/user.rb', line 62 def listed_count @listed_count end |
#location ⇒ String (readonly)
The user’s time zone
141 142 143 |
# File 'lib/twitter/user.rb', line 141 def location @location end |
#name ⇒ String (readonly)
The user’s time zone
141 142 143 |
# File 'lib/twitter/user.rb', line 141 def name @name end |
#profile_background_color ⇒ String (readonly)
The user’s time zone
141 142 143 |
# File 'lib/twitter/user.rb', line 141 def profile_background_color @profile_background_color end |
#profile_link_color ⇒ String (readonly)
The user’s time zone
141 142 143 |
# File 'lib/twitter/user.rb', line 141 def profile_link_color @profile_link_color end |
#profile_sidebar_border_color ⇒ String (readonly)
The user’s time zone
141 142 143 |
# File 'lib/twitter/user.rb', line 141 def @profile_sidebar_border_color end |
#profile_sidebar_fill_color ⇒ String (readonly)
The user’s time zone
141 142 143 |
# File 'lib/twitter/user.rb', line 141 def @profile_sidebar_fill_color end |
#profile_text_color ⇒ String (readonly)
The user’s time zone
141 142 143 |
# File 'lib/twitter/user.rb', line 141 def profile_text_color @profile_text_color end |
#statuses_count ⇒ Integer (readonly) Also known as: tweets_count
The UTC offset in seconds
62 63 64 |
# File 'lib/twitter/user.rb', line 62 def statuses_count @statuses_count end |
#time_zone ⇒ String (readonly)
The user’s time zone
141 142 143 |
# File 'lib/twitter/user.rb', line 141 def time_zone @time_zone end |
#utc_offset ⇒ Integer (readonly)
The UTC offset in seconds
62 63 64 |
# File 'lib/twitter/user.rb', line 62 def utc_offset @utc_offset end |
Instance Method Details
#description_uris ⇒ Array<Twitter::Entity::URI> Also known as: description_urls
Returns an array of URIs in the user’s description
204 205 206 207 208 209 210 |
# File 'lib/twitter/user.rb', line 204 def description_uris empty_hash = {} # : Hash[Symbol, untyped] empty_array = [] # : Array[untyped] @attrs.fetch(:entities, empty_hash).fetch(:description, empty_hash).fetch(:urls, empty_array).collect do |url| # steep:ignore FallbackAny Entity::URI.new(url) end end |
#description_uris? ⇒ Boolean Also known as: description_urls?
Returns true if the user has description URIs
227 228 229 |
# File 'lib/twitter/user.rb', line 227 def description_uris? description_uris.any? end |
#entities? ⇒ Boolean
Returns true if the user has entities
288 289 290 |
# File 'lib/twitter/user.rb', line 288 def entities? !@attrs[:entities].nil? && @attrs[:entities].any? { |_, hash| hash[:urls].any? } end |
#uri ⇒ URI::Generic Also known as: url
Returns the URI to the user’s profile
299 300 301 |
# File 'lib/twitter/user.rb', line 299 def uri URI.parse("https://twitter.com/#{screen_name}") if screen_name? end |
#website ⇒ URI::Generic
Returns the user’s website URL
318 319 320 321 322 323 324 |
# File 'lib/twitter/user.rb', line 318 def website if website_uris? website_uris.first. else URI.parse(@attrs[:url]) unless @attrs[:url].nil? end end |
#website? ⇒ Boolean
Returns true if the user has a website
333 334 335 |
# File 'lib/twitter/user.rb', line 333 def website? !!(website_uris? || @attrs[:url]) end |
#website_uris ⇒ Array<Twitter::Entity::URI> Also known as: website_urls
Returns an array of URIs in the user’s website
246 247 248 249 250 251 252 |
# File 'lib/twitter/user.rb', line 246 def website_uris empty_hash = {} # : Hash[Symbol, untyped] empty_array = [] # : Array[untyped] @attrs.fetch(:entities, empty_hash).fetch(:url, empty_hash).fetch(:urls, empty_array).collect do |url| # steep:ignore FallbackAny Entity::URI.new(url) end end |
#website_uris? ⇒ Boolean Also known as: website_urls?
Returns true if the user has website URIs
269 270 271 |
# File 'lib/twitter/user.rb', line 269 def website_uris? website_uris.any? end |