Class: Twitter::User

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

Attributes inherited from Base

#attrs

Instance Method Summary collapse

Methods included from Creatable

#created_at

Methods inherited from Identity

#==, fetch, #id, #initialize, store

Methods inherited from Base

#[], attr_reader, 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) Also known as: contributors_enabled?

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) Also known as: default_profile?

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) Also known as: default_profile_image?

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) Also known as: follow_request_sent?

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) Also known as: geo_enabled?

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: is_translator?, translator, 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) Also known as: notifications?

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) Also known as: profile_background_tile?

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) Also known as: profile_use_background_image?

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) Also known as: protected?

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) Also known as: verified?

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:



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

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)


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

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:



58
59
60
# File 'lib/twitter/user.rb', line 58

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:



71
72
73
# File 'lib/twitter/user.rb', line 71

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)


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

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:



79
80
81
82
83
84
85
86
87
# File 'lib/twitter/user.rb', line 79

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:



95
96
97
# File 'lib/twitter/user.rb', line 95

def status
  @status ||= Twitter::Tweet.fetch_or_new(@attrs.dup[:status].merge(:user => @attrs.except(:status))) if status?
end

#status?Boolean

Returns:

  • (Boolean)


99
100
101
# File 'lib/twitter/user.rb', line 99

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