Class: CodewarsApi::User

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

Instance Method Summary collapse

Constructor Details

#initialize(username) ⇒ User


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

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

Instance Method Details

#clanObject


20
21
22
# File 'lib/codewars_api/user.rb', line 20

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

#honorObject


16
17
18
# File 'lib/codewars_api/user.rb', line 16

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

#katas_authoredObject


40
41
42
# File 'lib/codewars_api/user.rb', line 40

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

#katas_completedObject


44
45
46
# File 'lib/codewars_api/user.rb', line 44

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

#leaderboard_positionObject


24
25
26
# File 'lib/codewars_api/user.rb', line 24

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

#nameObject


12
13
14
# File 'lib/codewars_api/user.rb', line 12

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

#rank_languagesObject


36
37
38
# File 'lib/codewars_api/user.rb', line 36

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

#rank_overallObject


32
33
34
# File 'lib/codewars_api/user.rb', line 32

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

#skillsObject


28
29
30
# File 'lib/codewars_api/user.rb', line 28

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

#to_hObject


48
49
50
# File 'lib/codewars_api/user.rb', line 48

def to_h
  @response.to_h
end

#usernameObject


8
9
10
# File 'lib/codewars_api/user.rb', line 8

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