Sha256: bed259c326194e2154d501a520a8cabb697a1f3243f2017042e107df017dcaac

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

module Rubyoverflow
  class Badge < Base
    attr_reader :badge_id, :rank, :name, :description, :award_count, :tag_based, :user, :badges_recipients_url
  
    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
    
    def item_id
      @badge_id
    end
    
    #Retrieves all the users that have received the badge
    def get_recipients(parameters = {})
      if @badges_recipients_url
        hash,url =request(@badges_recipients_url, parameters)
        Users.new hash, url
      else
        nil
      end
    end
    
  end

  class BadgeDash < BaseDash
    property :badge_id
    property :rank
    property :name
    property :description
    property :award_count
    property :tag_based
    property :user
    property :badges_recipients_url
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubyoverflow-1.0.2 lib/rubyoverflow/badge.rb