module Sorare::Rewards::Transposer
TransposeAllocations transposes the computed allocations { 'league' => { 'rarity' => { 'division' => … } } } to a division based allocations { 'league' => { 'division' => { 'rarity' => … } } }
Public Class Methods
transpose_allocations(allocations)
click to toggle source
# File lib/sorare/rewards/transposer.rb, line 12 def self.transpose_allocations(allocations) allocations.keys.index_with do |league| transpose_league(allocations[league]) end end
transpose_league(allocations)
click to toggle source
# File lib/sorare/rewards/transposer.rb, line 18 def self.transpose_league(allocations) allocations.each_with_object({}) do |(rarity, league_allocations), hash| league_allocations.each do |division, supply| hash[division] = {} unless hash[division] hash[division][rarity] = supply end end end