basketball 0.0.26 → 0.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/lib/basketball/season/record.rb +31 -23
- data/lib/basketball/season/result.rb +1 -1
- data/lib/basketball/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3fdbeeaeb0a6e0382cc1af0031199691ac64ba039b3bfa4fa6bde0ac0bde2b17
|
|
4
|
+
data.tar.gz: 3ed2a71522e8aae3aa78cd5af06941f966341b01f4c85a81a04f772b561a349d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2b76fa1d6b90f0c93e49b73c44028792909d94da7a42a472c923e9c23ab504fdd3acfcf037696479fa2851e9cd106c83dca4b951ead2dc25b02e9d5d996eee2c
|
|
7
|
+
data.tar.gz: 6ef6f13785dc387ad3df3feeb55cd9d6f2619fa992cd866b38819d4e4c249862b7400c65c0a44552c7e483750068e7957e9776d35f37fbe05e993a08f4574802
|
data/.rubocop.yml
CHANGED
|
@@ -19,29 +19,9 @@ module Basketball
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def accept!(result)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
opponent: result.away_opponent,
|
|
26
|
-
score: result.home_score,
|
|
27
|
-
opponent_score: result.away_score,
|
|
28
|
-
home: true
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
add!(detail)
|
|
32
|
-
elsif result.away_opponent == self
|
|
33
|
-
detail = Detail.new(
|
|
34
|
-
date: result.date,
|
|
35
|
-
opponent: result.home_opponent,
|
|
36
|
-
score: result.away_score,
|
|
37
|
-
opponent_score: result.home_score,
|
|
38
|
-
home: false
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
add!(detail)
|
|
42
|
-
else
|
|
43
|
-
raise OpponentNotFoundError, "#{result} has no opponent for #{self}"
|
|
44
|
-
end
|
|
22
|
+
detail = result_to_detail(result)
|
|
23
|
+
|
|
24
|
+
add!(detail)
|
|
45
25
|
end
|
|
46
26
|
|
|
47
27
|
def detail_for(date)
|
|
@@ -99,6 +79,34 @@ module Basketball
|
|
|
99
79
|
def details_for(opponent_type = nil)
|
|
100
80
|
details.select { |d| opponent_type.nil? || d.opponent_type == opponent_type }
|
|
101
81
|
end
|
|
82
|
+
|
|
83
|
+
def result_to_detail(result)
|
|
84
|
+
base_args = {
|
|
85
|
+
date: result.date,
|
|
86
|
+
opponent_type: result.opponent_type
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
all_args =
|
|
90
|
+
if result.home_opponent == self
|
|
91
|
+
base_args.merge(
|
|
92
|
+
opponent: result.away_opponent,
|
|
93
|
+
score: result.home_score,
|
|
94
|
+
opponent_score: result.away_score,
|
|
95
|
+
home: true
|
|
96
|
+
)
|
|
97
|
+
elsif result.away_opponent == self
|
|
98
|
+
base_args.merge(
|
|
99
|
+
opponent: result.home_opponent,
|
|
100
|
+
score: result.away_score,
|
|
101
|
+
opponent_score: result.home_score,
|
|
102
|
+
home: false
|
|
103
|
+
)
|
|
104
|
+
else
|
|
105
|
+
raise OpponentNotFoundError, "#{result} has no opponent for #{self}"
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
Detail.new(**all_args)
|
|
109
|
+
end
|
|
102
110
|
end
|
|
103
111
|
end
|
|
104
112
|
end
|
|
@@ -11,7 +11,7 @@ module Basketball
|
|
|
11
11
|
|
|
12
12
|
attr_reader :game, :home_score, :away_score
|
|
13
13
|
|
|
14
|
-
def_delegators :game, :date, :home_opponent, :away_opponent, :teams
|
|
14
|
+
def_delegators :game, :date, :home_opponent, :away_opponent, :teams, :opponent_type
|
|
15
15
|
|
|
16
16
|
def initialize(game:, home_score:, away_score:)
|
|
17
17
|
raise ArgumentError, 'game is required' unless game
|
data/lib/basketball/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: basketball
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.27
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matthew Ruggio
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-07-
|
|
11
|
+
date: 2023-07-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: " This library is meant to serve as the domain for a basketball league/season
|
|
14
14
|
simulator/turn-based game. It models core ideas such as: players, general managers,
|