Class: Codeforces::Api::User

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_client) ⇒ User

Returns a new instance of User.



7
8
9
# File 'lib/codeforces/api/user.rb', line 7

def initialize(base_client)
  @client = base_client
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)



37
38
39
# File 'lib/codeforces/api/user.rb', line 37

def method_missing(method, *args, &block)
  client.send method, *args, &block
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



5
6
7
# File 'lib/codeforces/api/user.rb', line 5

def client
  @client
end

Instance Method Details

#info(handles, options = {}) ⇒ Object



11
12
13
14
15
16
# File 'lib/codeforces/api/user.rb', line 11

def info(handles, options = {})
  handles = [handles] unless handles.is_a?(Array)
  options[:data] ||= {}
  options[:data][:handles] = multi_values(handles)
  get("user.info", options)
end

#rated_list(options = {}) ⇒ Object



18
19
20
# File 'lib/codeforces/api/user.rb', line 18

def rated_list(options = {})
  get("user.ratedList", options)
end

#rating(handle, options = {}) ⇒ Object



22
23
24
25
26
# File 'lib/codeforces/api/user.rb', line 22

def rating(handle, options = {})
  options[:query] ||= {}
  options[:query].merge! :handle => handle
  get("user.rating", options)
end

#status(handle, options = {}) ⇒ Object



28
29
30
31
32
33
# File 'lib/codeforces/api/user.rb', line 28

def status(handle, options = {})
  options[:query] ||= {}
  options[:query].merge! :handle => handle
  options[:query].merge! paginate(options[:offset])
  get("user.status", options)
end