-
Notifications
You must be signed in to change notification settings - Fork 59
/
football_player.rb
68 lines (58 loc) · 1.76 KB
/
football_player.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
class FootballPlayer < ApplicationRecord
# select players who have postion as forward
scope :forwarders, -> { raise NotImplementedError }
# select goalkeepers
scope :goalkeepers, -> { raise NotImplementedError }
# select players from the country France
#
# Note - France country code is 'FRA'
scope :french_players, -> { raise NotImplementedError }
# Sort players by their rank
scope :order_by_rank, -> { raise NotImplementedError }
# Average goals per game = (total goals) / (total matches)
#
# If total matches or total goals is missing return nil
def average_goals_per_game
raise NotImplementedError
end
# Total penalty cards given = red_card + yellow_card
#
# If red_card or yellow_card is missing return nil
def total_penalty_cards
raise NotImplementedError
end
# Return the penalty succes rate of the player
# penalty_success_rate = (penalty_kicks_won * 100) / penalty_kicks_made
#
# if data is missing return nil
def penalty_success_rate
raise NotImplementedError
end
# create argentinian players
def self.import_argentinian_players
raise NotImplementedError
end
# Update the statistics of a player after a game
#
# The data is given as an array of the following type:
# [player name, goals, minutes_played, red_card, yellow_card]
# Eg-
# [
# ["Sergio Aguero", 2, 30, 0, 0]
# ["Messi", 1, 30, 1, 0]
# ...
# ...
# ["Ronaldo", 3, 20, 1, 0]
# ]
#
# Note: If you cannot find a player with given name, raise an
# `ActiveRecord::RecordNotFound` exception with the player's name as
# the message.
def self.update_statistics(stat)
raise NotImplementedError
end
# Delete the record associated with a player.
def self.ban(name)
raise NotImplementedError
end
end