basketball 0.0.26 → 0.0.27

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11631dcd181d791f3eb5d9ca7af6bbfab2527c1837302ac83d72ff77bd990345
4
- data.tar.gz: 4f9a808e1579e83d7ca7c811e1e75a82af919f1b9c53d9f5f67c9a4d2e846db2
3
+ metadata.gz: 3fdbeeaeb0a6e0382cc1af0031199691ac64ba039b3bfa4fa6bde0ac0bde2b17
4
+ data.tar.gz: 3ed2a71522e8aae3aa78cd5af06941f966341b01f4c85a81a04f772b561a349d
5
5
  SHA512:
6
- metadata.gz: 4e52ca8ea4a738af4dd3548b4332e60cac35cef0469c3a9e6698d7936358f624ddb30a79de5bfb54a43425ec83a9a20a77e7ec4f94663d9c6e2064f41d33f7ba
7
- data.tar.gz: b0b07ad92d1aacab9a0d5aaba9dea3713b12ae4f1deeb8bcf9b08fa3d95b6a857b0b4dd2237a8cb979e37aa651bd770c4413d324ea92875b7b004e3ffa85f6a8
6
+ metadata.gz: 2b76fa1d6b90f0c93e49b73c44028792909d94da7a42a472c923e9c23ab504fdd3acfcf037696479fa2851e9cd106c83dca4b951ead2dc25b02e9d5d996eee2c
7
+ data.tar.gz: 6ef6f13785dc387ad3df3feeb55cd9d6f2619fa992cd866b38819d4e4c249862b7400c65c0a44552c7e483750068e7957e9776d35f37fbe05e993a08f4574802
data/.rubocop.yml CHANGED
@@ -19,7 +19,7 @@ RSpec/NestedGroups:
19
19
  Max: 5
20
20
 
21
21
  RSpec/MultipleExpectations:
22
- Max: 2
22
+ Max: 10
23
23
 
24
24
  Metrics/ParameterLists:
25
25
  Max: 6
@@ -19,29 +19,9 @@ module Basketball
19
19
  end
20
20
 
21
21
  def accept!(result)
22
- if result.home_opponent == self
23
- detail = Detail.new(
24
- date: result.date,
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Basketball
4
- VERSION = '0.0.26'
4
+ VERSION = '0.0.27'
5
5
  end
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.26
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-10 00:00:00.000000000 Z
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,