sportdb-structs 0.3.1 → 0.4.0
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/CHANGELOG.md +1 -1
- data/lib/sportdb/structs/match.rb +52 -1
- data/lib/sportdb/structs/round.rb +6 -5
- data/lib/sportdb/structs/version.rb +2 -2
- data/lib/sportdb/structs.rb +34 -2
- 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: 70fb10b4bb83d5146eb004d6c3143045e0efa430095a091429c51695a15461c6
|
4
|
+
data.tar.gz: b8377ca328aec94770b9d7e90fc60b83cbf2264a4b9ce295af7acd4846586f78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edb013626541448b4f4211d2afc779f018fe27a7b2b33af99bfce9a0876d243d4ba4079677ce7e14e5911ad7e013992632600dd5bee0958db7fc37900ded7a55
|
7
|
+
data.tar.gz: '08964910e951e7c92ef3a46a5348b1111109d326d9aed0a41311a63047de63f6a11c21bffbe8cb0f5becdb78240b66ab17817e89b2eca53059ea7b8ed601756a'
|
data/CHANGELOG.md
CHANGED
@@ -178,8 +178,59 @@ class Match
|
|
178
178
|
# def scorei_str # pretty print (half time) scores; convenience method
|
179
179
|
# "#{@score1i}-#{@score2i}"
|
180
180
|
# end
|
181
|
-
end # class Match
|
182
181
|
|
182
|
+
|
183
|
+
def as_json
|
184
|
+
##
|
185
|
+
data = {}
|
186
|
+
|
187
|
+
## check round
|
188
|
+
if @round
|
189
|
+
data[:round ] = if round.is_a?( Integer )
|
190
|
+
"Matchday #{@round}"
|
191
|
+
else ## assume string
|
192
|
+
@round
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
|
197
|
+
data[:num] = @num if @num
|
198
|
+
if @date
|
199
|
+
## assume 2020-09-19 date format!!
|
200
|
+
data[:date] = @date.is_a?( String ) ? @date : @date.strftime('%Y-%m-%d')
|
201
|
+
|
202
|
+
data[:time] = @time if @time
|
203
|
+
end
|
204
|
+
|
205
|
+
data[:team1] = @team1.is_a?( String ) ? @team1 : @team1.name
|
206
|
+
data[:team2] = @team2.is_a?( String ) ? @team2 : @team2.name
|
207
|
+
|
208
|
+
data[:score] = {}
|
209
|
+
|
210
|
+
data[:score][:ht] = [@score1i, @score2i] if @score1i && @score2i
|
211
|
+
data[:score][:ft] = [@score1, @score2] if @score1 && @score2
|
212
|
+
data[:score][:et] = [@score1et, @score2et] if @score1et && @score2et
|
213
|
+
data[:score][:p] = [@score1p, @score2p] if @score1p && @score2p
|
214
|
+
|
215
|
+
data[:group] = @group if @group
|
216
|
+
|
217
|
+
=begin
|
218
|
+
"round": "Spieltag 1",
|
219
|
+
"date": "2020-09-19",
|
220
|
+
"team1": "Eintracht Frankfurt",
|
221
|
+
"team2": "Arminia Bielefeld",
|
222
|
+
"score": {
|
223
|
+
"ft": [
|
224
|
+
1,
|
225
|
+
1
|
226
|
+
]
|
227
|
+
}
|
228
|
+
=end
|
229
|
+
data
|
230
|
+
end
|
231
|
+
|
232
|
+
|
233
|
+
end # class Match
|
183
234
|
end # module Sports
|
184
235
|
|
185
236
|
|
@@ -18,18 +18,19 @@ module Sports
|
|
18
18
|
@auto = auto # auto-created (inline reference/header without proper definition before)
|
19
19
|
end
|
20
20
|
|
21
|
-
def pretty_print( printer )
|
22
|
-
## todo/check - how to display/format key - use () or not - why? why not?
|
21
|
+
def pretty_print( printer )
|
22
|
+
## todo/check - how to display/format key - use () or not - why? why not?
|
23
23
|
buf = String.new
|
24
24
|
buf << "<Round: "
|
25
25
|
buf << "(#{@num}) " if @num
|
26
26
|
buf << "#{@name}, "
|
27
|
-
buf << "#{@start_date}
|
27
|
+
buf << "#{@start_date}"
|
28
|
+
buf << " - #{@end_date}" if @start_date != @end_date
|
28
29
|
buf << " (knockout)" if @knockout
|
29
30
|
buf << " (auto)" if @auto
|
30
31
|
buf << ">"
|
31
|
-
|
32
|
-
printer.text( buf )
|
32
|
+
|
33
|
+
printer.text( buf )
|
33
34
|
end
|
34
35
|
end # class Round
|
35
36
|
end # module Sports
|
data/lib/sportdb/structs.rb
CHANGED
@@ -65,13 +65,45 @@ end # module Sports
|
|
65
65
|
|
66
66
|
|
67
67
|
|
68
|
+
|
69
|
+
|
70
|
+
##
|
71
|
+
## add all structs in SportDb::Import namespace too
|
72
|
+
module SportDb
|
73
|
+
module Import
|
74
|
+
Season = ::Season ## add a convenience alias for top-level Season class
|
75
|
+
|
76
|
+
## add "old" convenience aliases for structs - why? why not?
|
77
|
+
## todo/check: just use include Sports !!!!
|
78
|
+
Country = ::Sports::Country
|
79
|
+
League = ::Sports::League
|
80
|
+
Group = ::Sports::Group
|
81
|
+
Round = ::Sports::Round
|
82
|
+
Match = ::Sports::Match
|
83
|
+
Matchlist = ::Sports::Matchlist
|
84
|
+
Goal = ::Sports::Goal
|
85
|
+
Team = ::Sports::Team
|
86
|
+
NationalTeam = ::Sports::NationalTeam
|
87
|
+
Club = ::Sports::Club
|
88
|
+
Standings = ::Sports::Standings
|
89
|
+
TeamUsage = ::Sports::TeamUsage
|
90
|
+
|
91
|
+
Ground = ::Sports::Ground
|
92
|
+
|
93
|
+
Player = ::Sports::Player
|
94
|
+
|
95
|
+
EventInfo = ::Sports::EventInfo
|
96
|
+
end # module Import
|
97
|
+
end # module SportDb
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
68
102
|
#####
|
69
103
|
# note: add Sport and Football convenience alias - why? why not?
|
70
104
|
Sport = Sports
|
71
105
|
Football = Sports
|
72
106
|
|
73
107
|
|
74
|
-
|
75
|
-
|
76
108
|
puts SportDb::Module::Structs.banner # say hello
|
77
109
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportdb-structs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: alphabets
|