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
Returns a new instance of User.
5 6 7 8 |
# 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}") end |
Instance Method Details
#clan ⇒ Object
22 23 24 |
# File 'lib/codewars_api/user.rb', line 22 def clan @response.to_h['clan'] end |
#honor ⇒ Object
18 19 20 |
# File 'lib/codewars_api/user.rb', line 18 def honor @response.to_h['honor'] end |
#katas_authored ⇒ Object
42 43 44 |
# File 'lib/codewars_api/user.rb', line 42 def @response.to_h['codeChallenges'].andand['totalAuthored'] end |
#katas_completed ⇒ Object
46 47 48 |
# File 'lib/codewars_api/user.rb', line 46 def katas_completed @response.to_h['codeChallenges'].andand['totalCompleted'] end |
#leaderboard_position ⇒ Object
26 27 28 |
# File 'lib/codewars_api/user.rb', line 26 def leaderboard_position @response.to_h['leaderboardPosition'] end |
#name ⇒ Object
14 15 16 |
# File 'lib/codewars_api/user.rb', line 14 def name @response.to_h['name'] end |
#rank_languages ⇒ Object
38 39 40 |
# File 'lib/codewars_api/user.rb', line 38 def rank_languages @response.to_h['ranks'].andand['languages'] end |
#rank_overall ⇒ Object
34 35 36 |
# File 'lib/codewars_api/user.rb', line 34 def rank_overall @response.to_h['ranks'].andand['overall'] end |
#skills ⇒ Object
30 31 32 |
# File 'lib/codewars_api/user.rb', line 30 def skills @response.to_h['skills'] end |
#username ⇒ Object
10 11 12 |
# File 'lib/codewars_api/user.rb', line 10 def username @response.to_h['username'] end |