Class: Rubyoverflow::User

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

change_end_point, client, convert_if_array, convert_to_id_list, #find_parse_querystring, request, #request

Constructor Details

#initialize(hash, request_path = '') ⇒ User

Returns a new instance of User.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/rubyoverflow/user.rb', line 10

def initialize(hash, request_path = '')
  dash = UserDash.new hash

  @user_id = dash.user_id
  @user_type = dash.user_type
  @creation_date = dash.creation_date
  @display_name = dash.display_name
  @reputation = dash.reputation
  @email_hash = dash.email_hash
  @age = dash.age
  @last_access_date = dash.last_access_date
  @website_url = dash.website_url
  @location = dash.location
  @about_me = dash.about_me
  @question_count = dash.question_count
  @answer_count = dash.answer_count
  @view_count = dash.view_count
  @up_vote_count = dash.up_vote_count
  @down_vote_count = dash.down_vote_count
  @accept_rate = dash.accept_rate
  @user_questions_url = dash.user_questions_url
  @user_answers_url = dash.user_answers_url
  @user_favorites_url = dash.user_favorites_url
  @user_tags_url = dash.user_tags_url
  @user_badges_url = dash.user_badges_url
  @user_timeline_url = dash.user_timeline_url
  @user_mentioned_url = dash.user_mentioned_url
  @user_comments_url = dash.user_comments_url
  @user_reputation_url = dash.user_reputation_url
  @badge_counts = BadgeCounts.new dash.badge_counts if dash.badge_counts
  @timed_penalty_date = dash.timed_penalty_date
  @association_id = dash.association_id
  @on_site = ApiSite.new dash.on_site if dash.on_site
end

Instance Attribute Details

#about_meObject (readonly)

Returns the value of attribute about_me.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def about_me
  @about_me
end

#accept_rateObject (readonly)

Returns the value of attribute accept_rate.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def accept_rate
  @accept_rate
end

#ageObject (readonly)

Returns the value of attribute age.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def age
  @age
end

#answer_countObject (readonly)

Returns the value of attribute answer_count.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def answer_count
  @answer_count
end

#association_idObject (readonly)

Returns the value of attribute association_id.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def association_id
  @association_id
end

#badge_countsObject (readonly)

Returns the value of attribute badge_counts.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def badge_counts
  @badge_counts
end

#creation_dateObject (readonly)

Returns the value of attribute creation_date.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def creation_date
  @creation_date
end

#display_nameObject (readonly)

Returns the value of attribute display_name.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def display_name
  @display_name
end

#down_vote_countObject (readonly)

Returns the value of attribute down_vote_count.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def down_vote_count
  @down_vote_count
end

#email_hashObject (readonly)

Returns the value of attribute email_hash.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def email_hash
  @email_hash
end

#last_access_dateObject (readonly)

Returns the value of attribute last_access_date.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def last_access_date
  @last_access_date
end

#locationObject (readonly)

Returns the value of attribute location.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def location
  @location
end

#on_siteObject (readonly)

Returns the value of attribute on_site.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def on_site
  @on_site
end

#question_countObject (readonly)

Returns the value of attribute question_count.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def question_count
  @question_count
end

#reputationObject (readonly)

Returns the value of attribute reputation.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def reputation
  @reputation
end

#timed_penalty_dateObject (readonly)

Returns the value of attribute timed_penalty_date.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def timed_penalty_date
  @timed_penalty_date
end

#up_vote_countObject (readonly)

Returns the value of attribute up_vote_count.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def up_vote_count
  @up_vote_count
end

#user_answers_urlObject (readonly)

Returns the value of attribute user_answers_url.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def user_answers_url
  @user_answers_url
end

#user_badges_urlObject (readonly)

Returns the value of attribute user_badges_url.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def user_badges_url
  @user_badges_url
end

#user_comments_urlObject (readonly)

Returns the value of attribute user_comments_url.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def user_comments_url
  @user_comments_url
end

#user_favorites_urlObject (readonly)

Returns the value of attribute user_favorites_url.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def user_favorites_url
  @user_favorites_url
end

#user_idObject (readonly)

Returns the value of attribute user_id.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def user_id
  @user_id
end

#user_mentioned_urlObject (readonly)

Returns the value of attribute user_mentioned_url.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def user_mentioned_url
  @user_mentioned_url
end

#user_questions_urlObject (readonly)

Returns the value of attribute user_questions_url.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def user_questions_url
  @user_questions_url
end

#user_reputation_urlObject (readonly)

Returns the value of attribute user_reputation_url.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def user_reputation_url
  @user_reputation_url
end

#user_tags_urlObject (readonly)

Returns the value of attribute user_tags_url.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def user_tags_url
  @user_tags_url
end

#user_timeline_urlObject (readonly)

Returns the value of attribute user_timeline_url.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def user_timeline_url
  @user_timeline_url
end

#user_typeObject (readonly)

Returns the value of attribute user_type.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def user_type
  @user_type
end

#view_countObject (readonly)

Returns the value of attribute view_count.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def view_count
  @view_count
end

#website_urlObject (readonly)

Returns the value of attribute website_url.



4
5
6
# File 'lib/rubyoverflow/user.rb', line 4

def website_url
  @website_url
end

Instance Method Details

#get_answers(parameters = {}) ⇒ Object

Gets the answers from the user



60
61
62
63
64
65
66
67
# File 'lib/rubyoverflow/user.rb', line 60

def get_answers(parameters = {})
  if @user_answers_url
    hash,url =request(@user_answers_url, parameters)
    Answers.new hash, url
  else
    nil
  end
end

#get_badgesObject

Gets the badges awared to the user



90
91
92
93
94
95
96
97
# File 'lib/rubyoverflow/user.rb', line 90

def get_badges
  if @user_badges_url
    hash,url =request(@user_badges_url,{})
    Badges.new hash, url
  else
    nil
  end
end

#get_comments(parameters = {}) ⇒ Object

Gets the comments by the user



120
121
122
123
124
125
126
127
# File 'lib/rubyoverflow/user.rb', line 120

def get_comments(parameters = {})
  if @user_comments_url
    hash,url =request(@user_comments_url, parameters)
    Comments.new hash, url
  else
    nil
  end
end

#get_favorites(parameters = {}) ⇒ Object

Gets the questions favorited by the user



70
71
72
73
74
75
76
77
# File 'lib/rubyoverflow/user.rb', line 70

def get_favorites(parameters = {})
  if @user_favorites_url
    hash,url =request(@user_favorites_url, parameters)
    Questions.new hash, url
  else
    nil
  end
end

#get_mentioned(parameters = {}) ⇒ Object

Gets the comments that mention the user



110
111
112
113
114
115
116
117
# File 'lib/rubyoverflow/user.rb', line 110

def get_mentioned(parameters = {})
  if @user_mentioned_url
    hash,url =request(@user_mentioned_url, parameters)
    Comments.new hash, url
  else
    nil
  end
end

#get_questions(parameters = {}) ⇒ Object

Gets the questions by the user



50
51
52
53
54
55
56
57
# File 'lib/rubyoverflow/user.rb', line 50

def get_questions(parameters = {})
  if @user_questions_url
    hash,url =request(@user_questions_url, parameters)
    Questions.new hash, url
  else
    nil
  end
end

#get_reputation(parameters = {}) ⇒ Object

Gets the user’s reputation



130
131
132
133
134
135
136
137
# File 'lib/rubyoverflow/user.rb', line 130

def get_reputation(parameters = {})
  if @user_reputation_url
    hash,url =request(@user_reputation_url, parameters)
    RepChanges.new hash, url
  else
    nil
  end
end

#get_tags(parameters = {}) ⇒ Object

Gets the tags the user has participated in



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

def get_tags(parameters = {})
  if @user_tags_url
    hash,url =request(@user_tags_url, parameters)
    Tags.new hash, url
  else
    nil
  end
end

#get_timeline(parameters = {}) ⇒ Object

Gets the user’s timeline



100
101
102
103
104
105
106
107
# File 'lib/rubyoverflow/user.rb', line 100

def get_timeline(parameters = {})
  if @user_timeline_url
    hash,url =request(@user_timeline_url, parameters)
    UserTimelineEvents.new hash, url
  else
    nil
  end
end

#item_idObject



45
46
47
# File 'lib/rubyoverflow/user.rb', line 45

def item_id
  @user_id
end

#retrieve_associated_accountsObject

Gets the user’s other accounts



140
141
142
143
144
145
146
# File 'lib/rubyoverflow/user.rb', line 140

def retrieve_associated_accounts
  if @association_id
    Users.retrieve_associated_accounts @association_id
  else
    nil
  end
end