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, favorites_count, favourite_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_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:



48
49
50
51
52
53
54
55
56
# File 'lib/twitter/user.rb', line 48

def profile_image_url(size=:normal)
  # The profile image URL comes in looking like like this:
  # http://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png
  # It can be converted to any of the following sizes:
  # http://a0.twimg.com/profile_images/1759857427/image1326743606.png
  # http://a0.twimg.com/profile_images/1759857427/image1326743606_mini.png
  # http://a0.twimg.com/profile_images/1759857427/image1326743606_bigger.png
  resize_profile_image_url(@attrs[:profile_image_url], size)
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:



62
63
64
65
66
67
68
69
70
# File 'lib/twitter/user.rb', line 62

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)
end

#statusTwitter::Tweet

Returns:



73
74
75
# File 'lib/twitter/user.rb', line 73

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

#status?Boolean

Returns:

  • (Boolean)


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

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