Class: Twitter::User

Inherits:
BasicUser show all
Includes:
Creatable, Profile
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

Attributes inherited from BasicUser

#screen_name

Attributes inherited from Identity

#id

Attributes inherited from Base

#attrs

Instance Method Summary collapse

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

#created?, #created_at

Methods inherited from Identity

#initialize

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

flat_pmap, pmap

Constructor Details

This class inherits a constructor from Twitter::Identity

Instance Attribute Details

#connectionsArray (readonly)

The user’s connections

Examples:

user.connections

Returns:

  • (Array)


19
20
21
# File 'lib/twitter/user.rb', line 19

def connections
  @connections
end

#descriptionString (readonly)

The user’s time zone

Examples:

user.time_zone

Returns:

  • (String)


141
142
143
# File 'lib/twitter/user.rb', line 141

def description
  @description
end

#emailString (readonly)

The user’s time zone

Examples:

user.time_zone

Returns:

  • (String)


141
142
143
# File 'lib/twitter/user.rb', line 141

def email
  @email
end

#favourites_countInteger (readonly) Also known as: favorites_count

The UTC offset in seconds

Examples:

user.utc_offset

Returns:

  • (Integer)


62
63
64
# File 'lib/twitter/user.rb', line 62

def favourites_count
  @favourites_count
end

#followers_countInteger (readonly)

The UTC offset in seconds

Examples:

user.utc_offset

Returns:

  • (Integer)


62
63
64
# File 'lib/twitter/user.rb', line 62

def followers_count
  @followers_count
end

#friends_countInteger (readonly)

The UTC offset in seconds

Examples:

user.utc_offset

Returns:

  • (Integer)


62
63
64
# File 'lib/twitter/user.rb', line 62

def friends_count
  @friends_count
end

#langString (readonly)

The user’s time zone

Examples:

user.time_zone

Returns:

  • (String)


141
142
143
# File 'lib/twitter/user.rb', line 141

def lang
  @lang
end

#listed_countInteger (readonly)

The UTC offset in seconds

Examples:

user.utc_offset

Returns:

  • (Integer)


62
63
64
# File 'lib/twitter/user.rb', line 62

def listed_count
  @listed_count
end

#locationString (readonly)

The user’s time zone

Examples:

user.time_zone

Returns:

  • (String)


141
142
143
# File 'lib/twitter/user.rb', line 141

def location
  @location
end

#nameString (readonly)

The user’s time zone

Examples:

user.time_zone

Returns:

  • (String)


141
142
143
# File 'lib/twitter/user.rb', line 141

def name
  @name
end

#profile_background_colorString (readonly)

The user’s time zone

Examples:

user.time_zone

Returns:

  • (String)


141
142
143
# File 'lib/twitter/user.rb', line 141

def profile_background_color
  @profile_background_color
end

The user’s time zone

Examples:

user.time_zone

Returns:

  • (String)


141
142
143
# File 'lib/twitter/user.rb', line 141

def profile_link_color
  @profile_link_color
end

#profile_sidebar_border_colorString (readonly)

The user’s time zone

Examples:

user.time_zone

Returns:

  • (String)


141
142
143
# File 'lib/twitter/user.rb', line 141

def profile_sidebar_border_color
  @profile_sidebar_border_color
end

#profile_sidebar_fill_colorString (readonly)

The user’s time zone

Examples:

user.time_zone

Returns:

  • (String)


141
142
143
# File 'lib/twitter/user.rb', line 141

def profile_sidebar_fill_color
  @profile_sidebar_fill_color
end

#profile_text_colorString (readonly)

The user’s time zone

Examples:

user.time_zone

Returns:

  • (String)


141
142
143
# File 'lib/twitter/user.rb', line 141

def profile_text_color
  @profile_text_color
end

#statuses_countInteger (readonly) Also known as: tweets_count

The UTC offset in seconds

Examples:

user.utc_offset

Returns:

  • (Integer)


62
63
64
# File 'lib/twitter/user.rb', line 62

def statuses_count
  @statuses_count
end

#time_zoneString (readonly)

The user’s time zone

Examples:

user.time_zone

Returns:

  • (String)


141
142
143
# File 'lib/twitter/user.rb', line 141

def time_zone
  @time_zone
end

#utc_offsetInteger (readonly)

The UTC offset in seconds

Examples:

user.utc_offset

Returns:

  • (Integer)


62
63
64
# File 'lib/twitter/user.rb', line 62

def utc_offset
  @utc_offset
end

Instance Method Details

#description_urisArray<Twitter::Entity::URI> Also known as: description_urls

Returns an array of URIs in the user’s description

Examples:

user.description_uris

Returns:



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

Examples:

user.description_uris?

Returns:

  • (Boolean)


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

Examples:

user.entities?

Returns:

  • (Boolean)


288
289
290
# File 'lib/twitter/user.rb', line 288

def entities?
  !@attrs[:entities].nil? && @attrs[:entities].any? { |_, hash| hash[:urls].any? }
end

#uriURI::Generic Also known as: url

Returns the URI to the user’s profile

Examples:

user.uri

Returns:

  • (URI::Generic)


299
300
301
# File 'lib/twitter/user.rb', line 299

def uri
  URI.parse("https://twitter.com/#{screen_name}") if screen_name?
end

#websiteURI::Generic

Returns the user’s website URL

Examples:

user.website

Returns:

  • (URI::Generic)


318
319
320
321
322
323
324
# File 'lib/twitter/user.rb', line 318

def website
  if website_uris?
    website_uris.first.expanded_url
  else
    URI.parse(@attrs[:url]) unless @attrs[:url].nil?
  end
end

#website?Boolean

Returns true if the user has a website

Examples:

user.website?

Returns:

  • (Boolean)


333
334
335
# File 'lib/twitter/user.rb', line 333

def website?
  !!(website_uris? || @attrs[:url])
end

#website_urisArray<Twitter::Entity::URI> Also known as: website_urls

Returns an array of URIs in the user’s website

Examples:

user.website_uris

Returns:



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

Examples:

user.website_uris?

Returns:

  • (Boolean)


269
270
271
# File 'lib/twitter/user.rb', line 269

def website_uris?
  website_uris.any?
end