Class: CForces::User

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#rankObject (readonly)

Returns the value of attribute rank.



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

def rank
  @rank
end

#ratingObject (readonly)

Returns the value of attribute rating.



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

def rating
  @rating
end