Class: ChessApi::PlayerResource

Inherits:
Resource
  • Object
show all
Includes:
InputHelpers
Defined in:
lib/chess_api/resources/players.rb

Defined Under Namespace

Modules: OnlineStatus

Instance Attribute Summary

Attributes inherited from Resource

#client

Instance Method Summary collapse

Methods included from InputHelpers

#downcased_username, #upcased_title_abbreviation

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from ChessApi::Resource

Instance Method Details

#clubs(username:) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/chess_api/resources/players.rb', line 25

def clubs(username:)
  @username = username

  ChessApi::Collection.from_response(
    get_request("player/#{downcased_username}/clubs"),
    key: "clubs",
    type: ChessApi::Club
  )
end

#online_status(username:) ⇒ Object



18
19
20
21
22
23
# File 'lib/chess_api/resources/players.rb', line 18

def online_status(username:)
  @username = username
  is_online = get_request("player/#{downcased_username}/is-online").body["online"]

  is_online ? OnlineStatus::ONLINE : OnlineStatus::OFFLINE
end

#retrieve(username:) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/chess_api/resources/players.rb', line 10

def retrieve(username:)
  @username = username

  ChessApi::Player.new(
    get_request("player/#{downcased_username}").body
  )
end