Class: Twitter::User

Inherits:
BasicUser show all
Includes:
Creatable, Exceptable
Defined in:
lib/twitter/user.rb

Constant Summary collapse

PROFILE_IMAGE_SUFFIX_REGEX =
/_normal(\.gif|\.jpe?g|\.png)$/

Instance Attribute Summary collapse

Attributes inherited from BasicUser

#following, #screen_name

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

#connectionsObject (readonly)

Returns the value of attribute connections.



10
11
12
# File 'lib/twitter/user.rb', line 10

def connections
  @connections
end

#contributors_enabledObject (readonly)

Returns the value of attribute contributors_enabled.



10
11
12
# File 'lib/twitter/user.rb', line 10

def contributors_enabled
  @contributors_enabled
end

#default_profileObject (readonly)

Returns the value of attribute default_profile.



10
11
12
# File 'lib/twitter/user.rb', line 10

def default_profile
  @default_profile
end

#default_profile_imageObject (readonly)

Returns the value of attribute default_profile_image.



10
11
12
# File 'lib/twitter/user.rb', line 10

def default_profile_image
  @default_profile_image
end

#descriptionObject (readonly)

Returns the value of attribute description.



10
11
12
# File 'lib/twitter/user.rb', line 10

def description
  @description
end

#favourites_countObject (readonly) Also known as: favorite_count, favoriters_count, favorites_count, favourite_count, favouriters_count

Returns the value of attribute favourites_count.



10
11
12
# File 'lib/twitter/user.rb', line 10

def favourites_count
  @favourites_count
end

#follow_request_sentObject (readonly)

Returns the value of attribute follow_request_sent.



10
11
12
# File 'lib/twitter/user.rb', line 10

def follow_request_sent
  @follow_request_sent
end

#followers_countObject (readonly) Also known as: follower_count

Returns the value of attribute followers_count.



10
11
12
# File 'lib/twitter/user.rb', line 10

def followers_count
  @followers_count
end

#friends_countObject (readonly) Also known as: friend_count

Returns the value of attribute friends_count.



10
11
12
# File 'lib/twitter/user.rb', line 10

def friends_count
  @friends_count
end

#geo_enabledObject (readonly)

Returns the value of attribute geo_enabled.



10
11
12
# File 'lib/twitter/user.rb', line 10

def geo_enabled
  @geo_enabled
end

#is_translatorObject (readonly) Also known as: translator

Returns the value of attribute is_translator.



10
11
12
# File 'lib/twitter/user.rb', line 10

def is_translator
  @is_translator
end

#langObject (readonly)

Returns the value of attribute lang.



10
11
12
# File 'lib/twitter/user.rb', line 10

def lang
  @lang
end

#listed_countObject (readonly)

Returns the value of attribute listed_count.



10
11
12
# File 'lib/twitter/user.rb', line 10

def listed_count
  @listed_count
end

#locationObject (readonly)

Returns the value of attribute location.



10
11
12
# File 'lib/twitter/user.rb', line 10

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/twitter/user.rb', line 10

def name
  @name
end

#notificationsObject (readonly)

Returns the value of attribute notifications.



10
11
12
# File 'lib/twitter/user.rb', line 10

def notifications
  @notifications
end

#profile_background_colorObject (readonly)

Returns the value of attribute profile_background_color.



10
11
12
# File 'lib/twitter/user.rb', line 10

def profile_background_color
  @profile_background_color
end

#profile_background_image_urlObject (readonly)

Returns the value of attribute profile_background_image_url.



10
11
12
# File 'lib/twitter/user.rb', line 10

def profile_background_image_url
  @profile_background_image_url
end

#profile_background_image_url_httpsObject (readonly)

Returns the value of attribute profile_background_image_url_https.



10
11
12
# File 'lib/twitter/user.rb', line 10

def profile_background_image_url_https
  @profile_background_image_url_https
end

#profile_background_tileObject (readonly)

Returns the value of attribute profile_background_tile.



10
11
12
# File 'lib/twitter/user.rb', line 10

def profile_background_tile
  @profile_background_tile
end

Returns the value of attribute profile_link_color.



10
11
12
# File 'lib/twitter/user.rb', line 10

def profile_link_color
  @profile_link_color
end

#profile_sidebar_border_colorObject (readonly)

Returns the value of attribute profile_sidebar_border_color.



10
11
12
# File 'lib/twitter/user.rb', line 10

def profile_sidebar_border_color
  @profile_sidebar_border_color
end

#profile_sidebar_fill_colorObject (readonly)

Returns the value of attribute profile_sidebar_fill_color.



10
11
12
# File 'lib/twitter/user.rb', line 10

def profile_sidebar_fill_color
  @profile_sidebar_fill_color
end

#profile_text_colorObject (readonly)

Returns the value of attribute profile_text_color.



10
11
12
# File 'lib/twitter/user.rb', line 10

def profile_text_color
  @profile_text_color
end

#profile_use_background_imageObject (readonly)

Returns the value of attribute profile_use_background_image.



10
11
12
# File 'lib/twitter/user.rb', line 10

def profile_use_background_image
  @profile_use_background_image
end

#protectedObject (readonly)

Returns the value of attribute protected.



10
11
12
# File 'lib/twitter/user.rb', line 10

def protected
  @protected
end

#statuses_countObject (readonly) Also known as: status_count, tweet_count, tweets_count, update_count, updates_count

Returns the value of attribute statuses_count.



10
11
12
# File 'lib/twitter/user.rb', line 10

def statuses_count
  @statuses_count
end

#time_zoneObject (readonly)

Returns the value of attribute time_zone.



10
11
12
# File 'lib/twitter/user.rb', line 10

def time_zone
  @time_zone
end

#urlObject (readonly)

Returns the value of attribute url.



10
11
12
# File 'lib/twitter/user.rb', line 10

def url
  @url
end

#utc_offsetObject (readonly)

Returns the value of attribute utc_offset.



10
11
12
# File 'lib/twitter/user.rb', line 10

def utc_offset
  @utc_offset
end

#verifiedObject (readonly)

Returns the value of attribute verified.



10
11
12
# File 'lib/twitter/user.rb', line 10

def verified
  @verified
end

Instance Method Details

#profile_banner_url(size = :web) ⇒ String

Return the URL to the user's profile banner image

Parameters:

  • size (String, Symbol) (defaults to: :web)

    The size of the image. Must be one of: 'mobile', 'mobile_retina', 'web', 'web_retina', 'ipad', or 'ipad_retina'

Returns:

  • (String)


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

def profile_banner_url(size=:web)
  insecure_url([@attrs[:profile_banner_url], size].join('/')) if profile_banner_url?
end

#profile_banner_url?Boolean Also known as: profile_banner_url_https?

Returns:

  • (Boolean)


51
52
53
# File 'lib/twitter/user.rb', line 51

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

#profile_banner_url_https(size = :web) ⇒ String

Return the secure URL to the user's profile banner image

Parameters:

  • size (String, Symbol) (defaults to: :web)

    The size of the image. Must be one of: 'mobile', 'mobile_retina', 'web', 'web_retina', 'ipad', or 'ipad_retina'

Returns:

  • (String)


47
48
49
# File 'lib/twitter/user.rb', line 47

def profile_banner_url_https(size=:web)
  [@attrs[:profile_banner_url], size].join('/') if profile_banner_url?
end

#profile_image_url(size = :normal) ⇒ String

Return the URL to the user's profile image

Parameters:

  • size (String, Symbol) (defaults to: :normal)

    The size of the image. Must be one of: 'mini', 'normal', 'bigger' or 'original'

Returns:

  • (String)


60
61
62
# File 'lib/twitter/user.rb', line 60

def profile_image_url(size=:normal)
  insecure_url(profile_image_url_https(size)) if profile_image_url?
end

#profile_image_url?Boolean Also known as: profile_image_url_https?

Returns:

  • (Boolean)


78
79
80
# File 'lib/twitter/user.rb', line 78

def profile_image_url?
  !@attrs[:profile_image_url_https].nil?
end

#profile_image_url_https(size = :normal) ⇒ String

Return the secure URL to the user's profile image

Parameters:

  • size (String, Symbol) (defaults to: :normal)

    The size of the image. Must be one of: 'mini', 'normal', 'bigger' or 'original'

Returns:

  • (String)


68
69
70
71
72
73
74
75
76
# File 'lib/twitter/user.rb', line 68

def profile_image_url_https(size=:normal)
  # The profile image URL comes in looking like like this:
  # https://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png
  # It can be converted to any of the following sizes:
  # https://a0.twimg.com/profile_images/1759857427/image1326743606.png
  # https://a0.twimg.com/profile_images/1759857427/image1326743606_mini.png
  # https://a0.twimg.com/profile_images/1759857427/image1326743606_bigger.png
  resize_profile_image_url(@attrs[:profile_image_url_https], size) if profile_image_url?
end

#statusTwitter::Tweet

Returns:



84
85
86
# File 'lib/twitter/user.rb', line 84

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

#status?Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/twitter/user.rb', line 88

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