sportdb-structs 0.3.1 → 0.4.1

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: a3fbeabfa958e34c5c809d3b923d528818f6fac42b7e72165e49d5d77d60314c
4
- data.tar.gz: 746d77f86ac8f8e1b5f8c8a928ee43a34714707c3dc026627e7322d9db3752df
3
+ metadata.gz: faf7fb1cc04e4b64b9b738d2a402cce3d64ee318b0eb74d2fb6d5417d7b4569e
4
+ data.tar.gz: 3dceec77dca62a94c3644cb22ee1539093e1f41960ed4014ad7a0f8280c19a34
5
5
  SHA512:
6
- metadata.gz: 0fa12c96f27937106ac161ff8377f7a9a3a1b9ed100d756b87e3cbac82c4f1574a14eb1149a54328368485932d18bb73aa98738a82a59e720c56ec47f5fb3087
7
- data.tar.gz: 5271fbd2f5a510c44cf13520681397b541afa47481f33f475fe14ea910b5cc21bead7705838d4c0240ad2debab6fb489ae33e7b26e5c4c463e5120f009825203
6
+ metadata.gz: d48f278c7c27e8f7492ef2272725daf8c6dd3024ce5b72ea291157ad96c97857566ed131f3197b6e945d98107f6418557dc02d02f1c6c569f59d1595a264d6f0
7
+ data.tar.gz: 1e9a4f7680401b420010f4eca791b7739eef69316f5744533d8f44df7542f62aceceb359c5d5b4d659567fe7140e0014583a56dc286f6a8748959b9888e406c3
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.3.1
1
+ ### 0.4.1
2
2
 
3
3
  ### 0.0.1 / 2020-08-24
4
4
 
@@ -178,8 +178,62 @@ 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[:status] = @status if @status
216
+
217
+ data[:group] = @group if @group
218
+ data[:stage] = @stage if @stage
219
+
220
+ =begin
221
+ "round": "Spieltag 1",
222
+ "date": "2020-09-19",
223
+ "team1": "Eintracht Frankfurt",
224
+ "team2": "Arminia Bielefeld",
225
+ "score": {
226
+ "ft": [
227
+ 1,
228
+ 1
229
+ ]
230
+ }
231
+ =end
232
+ data
233
+ end
234
+
235
+
236
+ end # class Match
183
237
  end # module Sports
184
238
 
185
239
 
@@ -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} - #{@end_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
@@ -3,7 +3,7 @@ module SportDb
3
3
  module Module
4
4
  module Structs
5
5
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
6
- MINOR = 3
6
+ MINOR = 4
7
7
  PATCH = 1
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
@@ -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.3.1
4
+ version: 0.4.1
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-23 00:00:00.000000000 Z
11
+ date: 2024-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: alphabets