Class: CodewarsApi::User
- Inherits:
-
Object
- Object
- CodewarsApi::User
- Includes:
- Common
- Defined in:
- lib/codewars_api/user.rb
Instance Method Summary collapse
- #clan ⇒ Object
- #honor ⇒ Object
-
#initialize(id_or_username) ⇒ User
constructor
A new instance of User.
- #katas_authored ⇒ Object
- #katas_completed ⇒ Object
- #leaderboard_position ⇒ Object
- #name ⇒ Object
- #rank_languages ⇒ Object
- #rank_overall ⇒ Object
- #skills ⇒ Object
- #username ⇒ Object
Methods included from Common
Constructor Details
#initialize(id_or_username) ⇒ User
5 6 7 8 9 |
# File 'lib/codewars_api/user.rb', line 5 def initialize(id_or_username) fail 'Username or id is not set' unless id_or_username @response = RequestHelper.get("#{CodewarsApi::API_URL}/users/#{id_or_username}") ResponseChecker.check_errors(@response) end |
Instance Method Details
#clan ⇒ Object
23 24 25 |
# File 'lib/codewars_api/user.rb', line 23 def clan @response.to_h['clan'] end |
#honor ⇒ Object
19 20 21 |
# File 'lib/codewars_api/user.rb', line 19 def honor @response.to_h['honor'] end |
#katas_authored ⇒ Object
43 44 45 |
# File 'lib/codewars_api/user.rb', line 43 def @response.to_h['codeChallenges'].andand['totalAuthored'] end |
#katas_completed ⇒ Object
47 48 49 |
# File 'lib/codewars_api/user.rb', line 47 def katas_completed @response.to_h['codeChallenges'].andand['totalCompleted'] end |
#leaderboard_position ⇒ Object
27 28 29 |
# File 'lib/codewars_api/user.rb', line 27 def leaderboard_position @response.to_h['leaderboardPosition'] end |
#name ⇒ Object
15 16 17 |
# File 'lib/codewars_api/user.rb', line 15 def name @response.to_h['name'] end |
#rank_languages ⇒ Object
39 40 41 |
# File 'lib/codewars_api/user.rb', line 39 def rank_languages @response.to_h['ranks'].andand['languages'] end |
#rank_overall ⇒ Object
35 36 37 |
# File 'lib/codewars_api/user.rb', line 35 def rank_overall @response.to_h['ranks'].andand['overall'] end |
#skills ⇒ Object
31 32 33 |
# File 'lib/codewars_api/user.rb', line 31 def skills @response.to_h['skills'] end |
#username ⇒ Object
11 12 13 |
# File 'lib/codewars_api/user.rb', line 11 def username @response.to_h['username'] end |