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
|
# File 'lib/footballdata/stat.rb', line 10
def update( match )
stat = @data[:all] ||= { stage: Hash.new( 0 ),
duration: Hash.new( 0 ),
status: Hash.new( 0 ),
group: Hash.new( 0 ),
matchday: Hash.new( 0 ),
matches: 0,
goals: 0,
}
stat[:stage][ match['stage'] ] += 1
stat[:group][ match['group'] ] += 1
stat[:status][ match['status'] ] += 1
stat[:matchday][ match['matchday'] ] += 1
score = match['score']
stat[:duration][ score['duration'] ] += 1
stat[:matches] += 1
stat[:goals] += score['fullTime']['homeTeam'].to_i if score['fullTime']['homeTeam']
stat[:goals] += score['fullTime']['awayTeam'].to_i if score['fullTime']['awayTeam']
stage_key = match['stage'].downcase.to_sym
stat = @data[ stage_key ] ||= { duration: Hash.new( 0 ),
status: Hash.new( 0 ),
group: Hash.new( 0 ),
matchday: Hash.new( 0 ),
matches: 0,
goals: 0,
}
stat[:group][ match['group'] ] += 1
stat[:status][ match['status'] ] += 1
stat[:matchday][ match['matchday'] ] += 1
stat[:duration][ score['duration'] ] += 1
stat[:matches] += 1
stat[:goals] += score['fullTime']['homeTeam'].to_i if score['fullTime']['homeTeam']
stat[:goals] += score['fullTime']['awayTeam'].to_i if score['fullTime']['awayTeam']
end
|