Class: Gowalla::User

Inherits:
Base
  • Object
show all
Defined in:
lib/gowalla/user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ User

Returns a new instance of User.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gowalla/user.rb', line 5

def initialize(data={})
  @first_name = data['first_name']
  @last_name = data['last_name']
  @top_spots_url = data['top_spots_url']
  @image_url = data['image_url'] 
  @url = data['url']
  @activity_url = data['activity_url'] 
  @bio = data['bio'] 
  @stamps_count = data['stamps_count'] 
  @stamps_url = data['stamps_url'] 
  @items_count = data['items_count'] 
  @items_url = data['items_url'] 
  @friends_count = data['friends_count'] 
  @icons_count = data['icons_count'] 
  @hometown = data['hometown'] 
  @pins_url = data['pins_url'] 
  @website = data['website'] 
  @twitter_username = data['twitter_username']
  @facebook_id = data['facebook_id']
  @add_friend_url = data['add_friend_url']
  @friends_url = data['friends_url']
  @_is_friend = data['_is_friend']
  @last_checkins = data['last_checkins'].map{|checkin| Checkin.new(checkin)} unless data['last_checkins'].blank?
  @pins_count = data['pins_count']
end

Instance Attribute Details

#_is_friendObject

Returns the value of attribute _is_friend.



3
4
5
# File 'lib/gowalla/user.rb', line 3

def _is_friend
  @_is_friend
end

#activity_urlObject

Returns the value of attribute activity_url.



3
4
5
# File 'lib/gowalla/user.rb', line 3

def activity_url
  @activity_url
end

#add_friend_urlObject

Returns the value of attribute add_friend_url.



3
4
5
# File 'lib/gowalla/user.rb', line 3

def add_friend_url
  @add_friend_url
end

#bioObject

Returns the value of attribute bio.



3
4
5
# File 'lib/gowalla/user.rb', line 3

def bio
  @bio
end

#facebook_idObject

Returns the value of attribute facebook_id.



3
4
5
# File 'lib/gowalla/user.rb', line 3

def facebook_id
  @facebook_id
end

#first_nameObject

Returns the value of attribute first_name.



3
4
5
# File 'lib/gowalla/user.rb', line 3

def first_name
  @first_name
end

#friends_countObject

Returns the value of attribute friends_count.



3
4
5
# File 'lib/gowalla/user.rb', line 3

def friends_count
  @friends_count
end

#friends_urlObject

Returns the value of attribute friends_url.



3
4
5
# File 'lib/gowalla/user.rb', line 3

def friends_url
  @friends_url
end

#hometownObject

Returns the value of attribute hometown.



3
4
5
# File 'lib/gowalla/user.rb', line 3

def hometown
  @hometown
end

#image_urlObject

Returns the value of attribute image_url.



3
4
5
# File 'lib/gowalla/user.rb', line 3

def image_url
  @image_url
end

#items_countObject

Returns the value of attribute items_count.



3
4
5
# File 'lib/gowalla/user.rb', line 3

def items_count
  @items_count
end

#items_urlObject

Returns the value of attribute items_url.



3
4
5
# File 'lib/gowalla/user.rb', line 3

def items_url
  @items_url
end

#last_checkinsObject

Returns the value of attribute last_checkins.



3
4
5
# File 'lib/gowalla/user.rb', line 3

def last_checkins
  @last_checkins
end

#last_nameObject

Returns the value of attribute last_name.



3
4
5
# File 'lib/gowalla/user.rb', line 3

def last_name
  @last_name
end

#pins_countObject

Returns the value of attribute pins_count.



3
4
5
# File 'lib/gowalla/user.rb', line 3

def pins_count
  @pins_count
end

#pins_urlObject

Returns the value of attribute pins_url.



3
4
5
# File 'lib/gowalla/user.rb', line 3

def pins_url
  @pins_url
end

#stamps_countObject

Returns the value of attribute stamps_count.



3
4
5
# File 'lib/gowalla/user.rb', line 3

def stamps_count
  @stamps_count
end

#stamps_urlObject

Returns the value of attribute stamps_url.



3
4
5
# File 'lib/gowalla/user.rb', line 3

def stamps_url
  @stamps_url
end

#top_spots_urlObject

Returns the value of attribute top_spots_url.



3
4
5
# File 'lib/gowalla/user.rb', line 3

def top_spots_url
  @top_spots_url
end

#twitter_usernameObject

Returns the value of attribute twitter_username.



3
4
5
# File 'lib/gowalla/user.rb', line 3

def twitter_username
  @twitter_username
end

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/gowalla/user.rb', line 3

def url
  @url
end

#websiteObject

Returns the value of attribute website.



3
4
5
# File 'lib/gowalla/user.rb', line 3

def website
  @website
end

Class Method Details

.find(username) ⇒ Object



30
31
32
# File 'lib/gowalla/user.rb', line 30

def self.find(username)
  User.new(self.fetch(username))
end

Instance Method Details

#stampsObject



33
34
35
36
37
# File 'lib/gowalla/user.rb', line 33

def stamps
  # TODO is there a better way to extract the user ID?
  user_id = self.add_friend_url.split("user_id=").last
  Stamp.find(user_id)
end