Class: Sorare::Rewards::GameWeekConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/sorare/rewards/game_week_config.rb

Overview

GameWeekConfig stores the config used to reward a game week

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ GameWeekConfig

Returns a new instance of GameWeekConfig.



11
12
13
# File 'lib/sorare/rewards/game_week_config.rb', line 11

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



9
10
11
# File 'lib/sorare/rewards/game_week_config.rb', line 9

def config
  @config
end

Instance Method Details

#cooldown_limit(rarity) ⇒ Object



29
30
31
# File 'lib/sorare/rewards/game_week_config.rb', line 29

def cooldown_limit(rarity)
  cooldown.dig(rarity, 'quantity')
end

#cooldown_per_league?(rarity) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
36
37
# File 'lib/sorare/rewards/game_week_config.rb', line 33

def cooldown_per_league?(rarity)
  per_league = cooldown.dig(rarity, 'per_league')

  per_league.nil? ? true : per_league
end

#cooldown_since(rarity) ⇒ Object



39
40
41
# File 'lib/sorare/rewards/game_week_config.rb', line 39

def cooldown_since(rarity)
  cooldown.dig(rarity, 'since')
end

#distribution_limit(rarity) ⇒ Object



25
26
27
# File 'lib/sorare/rewards/game_week_config.rb', line 25

def distribution_limit(rarity)
  limits[rarity] || 1
end

#over_limit?(rarity, rewarded) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/sorare/rewards/game_week_config.rb', line 21

def over_limit?(rarity, rewarded)
  limits[rarity] <= rewarded
end