Class: RiotKit::Facades::Player
- Inherits:
-
Object
- Object
- RiotKit::Facades::Player
- Defined in:
- lib/riot_kit/facades/player.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
readonly
Returns the value of attribute account.
Class Method Summary collapse
Instance Method Summary collapse
- #avg_matches_per_week ⇒ Object
- #display_riot_id ⇒ Object
-
#initialize(account:, config:) ⇒ Player
constructor
A new instance of Player.
- #match(match_id) ⇒ Object
-
#matches(filter = :ranked, reload: false, limit: Services::Riot::MatchHistory::DEFAULT_DETAIL_LIMIT) ⇒ Object
Memoized per Player, filter, and limit.
- #puuid ⇒ Object
- #ranked ⇒ Object
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 = account @config = config @matches_cache = {} end |
Instance Attribute Details
#account ⇒ Object (readonly)
Returns the value of attribute account.
17 18 19 |
# File 'lib/riot_kit/facades/player.rb', line 17 def account @account end |
Class Method Details
Instance Method Details
#avg_matches_per_week ⇒ Object
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_id ⇒ Object
29 30 31 |
# File 'lib/riot_kit/facades/player.rb', line 29 def display_riot_id account.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 |
#puuid ⇒ Object
25 26 27 |
# File 'lib/riot_kit/facades/player.rb', line 25 def puuid account.puuid end |
#ranked ⇒ Object
58 59 60 |
# File 'lib/riot_kit/facades/player.rb', line 58 def ranked Services::Riot::FetchRankedData.call(puuid: puuid, config: @config).value! end |