Sha256: 88bbb8aae67a358097b7d3559810e6dcb27111c9efd8ac36e21d863d03ae2aca

Contents?: true

Size: 955 Bytes

Versions: 2

Compression:

Stored size: 955 Bytes

Contents

module CodewarsApi
  class User
    def initialize(username)
      fail 'Username is not set' unless username
      @response = RequestHelper.get("#{CodewarsApi::API_URL}/users/#{username}")
    end

    def username
      @response.to_h['username']
    end

    def name
      @response.to_h['name']
    end

    def honor
      @response.to_h['honor']
    end

    def clan
      @response.to_h['clan']
    end

    def leaderboard_position
      @response.to_h['leaderboardPosition']
    end

    def skills
      @response.to_h['skills']
    end

    def rank_overall
      @response.to_h['ranks'].andand['overall']
    end

    def rank_languages
      @response.to_h['ranks'].andand['languages']
    end

    def katas_authored
      @response.to_h['codeChallenges'].andand['totalAuthored']
    end

    def katas_completed
      @response.to_h['codeChallenges'].andand['totalCompleted']
    end

    def to_h
      @response.to_h
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
codewars_api-0.1.1 lib/codewars_api/user.rb
codewars_api-0.1.0 lib/codewars_api/user.rb