Class: FortniteExperience::Calculator

Inherits:
Object
  • Object
show all
Defined in:
lib/fortnite_experience/calculator.rb

Instance Method Summary collapse

Constructor Details

#initialize(api_key) ⇒ Calculator

Returns a new instance of Calculator.



3
4
5
# File 'lib/fortnite_experience/calculator.rb', line 3

def initialize(api_key)
  @api_key = api_key
end

Instance Method Details

#experience_by_poisObject



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fortnite_experience/calculator.rb', line 7

def experience_by_pois
  result = {}

  Services::FortniteAPI.get_poi_names(@api_key).each do |poi|
    Services::FortniteAPI.get_weekly_challenges(@api_key).each do |challenge|
      if challenge['title'].match?(/#{poi}/i)
        result[poi] = (result[poi] || 0) + challenge['xp']
      end
    end
  end

  result
end