Class: CForces::User
- Inherits:
-
Object
- Object
- CForces::User
- Defined in:
- lib/codeforcesapi/API/user.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#rank ⇒ Object
readonly
Returns the value of attribute rank.
-
#rating ⇒ Object
readonly
Returns the value of attribute rating.
Instance Method Summary collapse
-
#initialize(user) ⇒ User
constructor
A new instance of User.
Constructor Details
#initialize(user) ⇒ User
Returns a new instance of User.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/codeforcesapi/API/user.rb', line 10 def initialize(user) @url = 'https://codeforces.com/api/user.info?handles='+user @user = JSON.parse(open(@url).read) if @user['status'] == 'OK' @rank = @user['result'].first['rank'] @rating = @user['result'].first['rating'] end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/codeforcesapi/API/user.rb', line 8 def name @name end |
#rank ⇒ Object (readonly)
Returns the value of attribute rank.
8 9 10 |
# File 'lib/codeforcesapi/API/user.rb', line 8 def rank @rank end |
#rating ⇒ Object (readonly)
Returns the value of attribute rating.
8 9 10 |
# File 'lib/codeforcesapi/API/user.rb', line 8 def @rating end |