Class: Rubyoverflow::Badge

Inherits:
Base
  • Object
show all
Defined in:
lib/rubyoverflow/badge.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 = '') ⇒ Badge

Returns a new instance of Badge.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/rubyoverflow/badge.rb', line 5

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

  @badge_id = dash.badge_id
  @rank = dash.rank
  @name = dash.name
  @description = dash.description
  @award_count = dash.award_count
  @tag_based = dash.tag_based
  @user = User.new dash.user if dash.user
  @badges_recipients_url = dash.badges_recipients_url
end

Instance Attribute Details

#award_countObject (readonly)

Returns the value of attribute award_count.



3
4
5
# File 'lib/rubyoverflow/badge.rb', line 3

def award_count
  @award_count
end

#badge_idObject (readonly)

Returns the value of attribute badge_id.



3
4
5
# File 'lib/rubyoverflow/badge.rb', line 3

def badge_id
  @badge_id
end

#badges_recipients_urlObject (readonly)

Returns the value of attribute badges_recipients_url.



3
4
5
# File 'lib/rubyoverflow/badge.rb', line 3

def badges_recipients_url
  @badges_recipients_url
end

#descriptionObject (readonly)

Returns the value of attribute description.



3
4
5
# File 'lib/rubyoverflow/badge.rb', line 3

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/rubyoverflow/badge.rb', line 3

def name
  @name
end

#rankObject (readonly)

Returns the value of attribute rank.



3
4
5
# File 'lib/rubyoverflow/badge.rb', line 3

def rank
  @rank
end

#tag_basedObject (readonly)

Returns the value of attribute tag_based.



3
4
5
# File 'lib/rubyoverflow/badge.rb', line 3

def tag_based
  @tag_based
end

#userObject (readonly)

Returns the value of attribute user.



3
4
5
# File 'lib/rubyoverflow/badge.rb', line 3

def user
  @user
end

Instance Method Details

#get_recipients(parameters = {}) ⇒ Object

Retrieves all the users that have received the badge



23
24
25
26
27
28
29
30
# File 'lib/rubyoverflow/badge.rb', line 23

def get_recipients(parameters = {})
  if @badges_recipients_url
    hash,url =request(@badges_recipients_url, parameters)
    Users.new hash, url
  else
    nil
  end
end

#item_idObject



18
19
20
# File 'lib/rubyoverflow/badge.rb', line 18

def item_id
  @badge_id
end