Class: RiotKit::Facades::Player

Inherits:
Object
  • Object
show all
Defined in:
lib/riot_kit/facades/player.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(account:, config:) ⇒ Player

Returns a new instance of Player.



19
20
21
22
23
# File 'lib/riot_kit/facades/player.rb', line 19

def initialize(account:, config:)
  @account = 
  @config = config
  @matches_cache = {}
end

Instance Attribute Details

#accountObject (readonly)

Returns the value of attribute account.



17
18
19
# File 'lib/riot_kit/facades/player.rb', line 17

def 
  @account
end

Class Method Details

.find(riot_id, config: RiotKit.config) ⇒ Object



12
13
14
15
# File 'lib/riot_kit/facades/player.rb', line 12

def self.find(riot_id, config: RiotKit.config)
   = Services::Riot::FetchAccount.call(riot_id: riot_id, config: config).value!
  new(account: , config: config)
end

Instance Method Details

#avg_matches_per_weekObject



62
63
64
# File 'lib/riot_kit/facades/player.rb', line 62

def avg_matches_per_week
  Services::Riot::FetchAvgMatchesPerWeek.call(puuid: puuid, config: @config).value!
end

#display_riot_idObject



29
30
31
# File 'lib/riot_kit/facades/player.rb', line 29

def display_riot_id
  .display_riot_id
end

#match(match_id) ⇒ Object



50
51
52
53
54
55
56
# File 'lib/riot_kit/facades/player.rb', line 50

def match(match_id)
  Services::Riot::MatchDetail.call(
    match_id: match_id,
    puuid: puuid,
    config: @config
  ).value!
end

#matches(filter = :ranked, reload: false, limit: Services::Riot::MatchHistory::DEFAULT_DETAIL_LIMIT) ⇒ Object

Memoized per Player, filter, and limit. Returns a lazy Enumerable — match-detail GETs run only while you iterate, so ‘matches.first` loads one detail (plus the match-id list API). Passes `puuid` from `find` so the history step skips GET /accounts/by-riot-id. Use `limit:` to cap how many distinct match ids may be detailed when you enumerate fully.



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/riot_kit/facades/player.rb', line 37

def matches(filter = :ranked, reload: false, limit: Services::Riot::MatchHistory::DEFAULT_DETAIL_LIMIT)
  cache_key = [filter.to_sym, limit]
  return @matches_cache[cache_key] if !reload && @matches_cache.key?(cache_key)

  @matches_cache[cache_key] = Models::Riot::LazyMatchEntries.build(
    nickname: display_riot_id,
    filter: filter,
    puuid: puuid,
    limit: limit,
    config: @config
  )
end

#puuidObject



25
26
27
# File 'lib/riot_kit/facades/player.rb', line 25

def puuid
  .puuid
end

#rankedObject



58
59
60
# File 'lib/riot_kit/facades/player.rb', line 58

def ranked
  Services::Riot::FetchRankedData.call(puuid: puuid, config: @config).value!
end