infostrada 0.1.25 → 0.1.26

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjU1YWFhNjRmN2NkNGJhMjAyZTk5NGRmMzNjNTg0ZmE3NWJlMzI3Ng==
4
+ OWUyODUxNWQ3NjMyYjVmNDAwYWRmMDE4OTdjZDQ2ZjQ5ZGZjMDNlYw==
5
5
  data.tar.gz: !binary |-
6
- MDllZmQwOGVkM2M2ZDdkNDdlOWE1YjgzMjI0ZjI4NGYwODhjNDRjNQ==
6
+ ZTlmMWIxYTFhM2Q2NTRlYmFhN2JjZTliOTM5ZjEwNDFlNGM0MmViZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Yjg4MzkwMjFjZGRmOWRkN2ZkZjEyZjVmMWIyOGYxODFlOGVlZDkzZTkwZjMx
10
- MDg5MTNhODE4MTM1NTMzNGM5MTdmMDE3MTQ2OTk3Mzk3ZThhZDc2ZDlhOGUw
11
- MmZkMTljY2RlOWU4Y2E2ZDNiNTlmYmQwODBmNDA0MmMyYzU3Mzk=
9
+ ZWZlMzA5YWNjODBhZWZjMmJjYzgyZjVjMDMwOTgzZWJjY2UzNjI1ZTUyNzNk
10
+ OWM0MmU2Mzg4ODZiYzdiYzc3Y2VhMTZkNmM0MzVkMTkyZTQ4NDJhMjMxZTUy
11
+ OTI0NmMyMTczOGI5MThlNzM2NTE2YzliYWMzNWIxZThjNzIzOGE=
12
12
  data.tar.gz: !binary |-
13
- MDZmNTc0NDJmMTlhMTUxMGZmZTg1ZDBhNDcwMjIwNGRjNzhmMzgyMGZjNmYx
14
- YzUyNjE3YTJmMzIwMTQxZjExZmE0YzFlMDFiNzVhMmZmODJlMmUzZjM3N2Ji
15
- M2MxYTI3NTZhOTMyNzJlM2RiZjU2ZTI1MGQyZDZiMDEwZTI4MTg=
13
+ OGQzZTYwMmIxN2JlZGY2NmY2YmU1MTQyMzY2OGRkYmRiYWIyODZjZThmODg4
14
+ ZjAyOTBmYmI0NGM0MzBiNWI1MmU0ZDQ2ZDllZThiOWU3YjJlYjU1OGQ1Mzg3
15
+ NWEyMzVlOGI4NGY1ODcwMjBlM2U2NmZjODhhMWE4ZGE0YzEyODc=
@@ -120,7 +120,7 @@ module Infostrada
120
120
  match.status_short = json['status_short']
121
121
  match.leg = json['leg']
122
122
  match.started_at = Time.parse(json['started_at']) if json['started_at']
123
- match.knockout_phase_id = hash['knockout_phase_id']
123
+ match.knockout_phase_id = json['knockout_phase_id']
124
124
 
125
125
  match.stadium_id = json['stadium_id']
126
126
  match.stadium_name = json['stadium_name']
@@ -141,30 +141,30 @@ module Infostrada
141
141
 
142
142
  match.period = json['period']
143
143
 
144
- match.referee = Referee.from_json(json['referee'])
145
- match.phase = Phase.from_json(json['phase'])
146
- match.home_team = Team.from_json(json['home_team'], 'home')
147
- match.away_team = Team.from_json(json['away_team'], 'away')
148
- match.goals = Goals.from_json(json['goals'])
149
- match.edition = Edition.from_json(json['edition'])
144
+ match.referee = Referee.from_json(json['referee']) if json['referee']
145
+ match.phase = Phase.from_json(json['phase']) if json['phase']
146
+ match.home_team = Team.from_json(json['home_team'], 'home') if json['home_team']
147
+ match.away_team = Team.from_json(json['away_team'], 'away') if json['away_team']
148
+ match.goals = Goals.from_json(json['goals']) if json['goals']
149
+ match.edition = Edition.from_json(json['edition']) if json['edition']
150
150
  end
151
151
  end
152
152
 
153
153
  def initialize(hash = {}, &block)
154
154
  @id = hash['n_MatchID']
155
- @date = Formatter.format_date(hash['d_DateUTC'])
155
+ @date = Formatter.format_date(hash['d_DateUTC']) if hash['d_DateUTC']
156
156
  @rescheduled = hash['b_RescheduledToBeResumed']
157
157
  @round = hash['n_RoundNr']
158
158
  @time_unknown = hash['b_TimeUnknown']
159
159
  @date_unknown = hash['b_DateUnknown']
160
160
 
161
161
  @aggregate_winner_id = hash['n_WinnerOnAggregateTeamID']
162
- @current_period_started_at = Formatter.format_date(hash['d_CurrentPeriodStartTime'])
162
+ @current_period_started_at = Formatter.format_date(hash['d_CurrentPeriodStartTime']) if hash['d_CurrentPeriodStartTime']
163
163
  @status_code = hash['n_MatchStatusCode']
164
164
  @status = hash['c_MatchStatus']
165
165
  @status_short = hash['c_MatchStatusShort']
166
166
  @leg = hash['n_Leg']
167
- @started_at = Formatter.format_date(hash['d_MatchStartTime'])
167
+ @started_at = Formatter.format_date(hash['d_MatchStartTime']) if hash['d_MatchStartTime']
168
168
  @knockout_phase_id = hash['n_KnockoutPhaseID']
169
169
 
170
170
  @stadium_id = hash['n_StadiumGeoID']
@@ -185,16 +185,14 @@ module Infostrada
185
185
  @lineup_official = hash['b_LineupOfficial']
186
186
 
187
187
  @period = hash['n_PeriodSort']
188
+ @referee = Referee.new(hash) if hash['n_RefereeID']
189
+ @phase = Phase.new(hash) if hash['n_PhaseID']
188
190
 
189
- @referee = Referee.new(hash)
190
- @phase = Phase.new(hash)
191
+ @home_team = Team.new(hash, 'home') if hash['n_EditionID']
192
+ @away_team = Team.new(hash, 'away') if hash['n_EditionID']
191
193
 
192
- @home_team = Team.new(hash, 'home')
193
- @away_team = Team.new(hash, 'away')
194
-
195
- @goals = Goals.new(hash)
196
-
197
- @edition = Edition.new(hash)
194
+ @goals = Goals.new(hash) if hash['n_HomeGoals']
195
+ @edition = Edition.new(hash) if hash['n_EditionID']
198
196
 
199
197
  block.call(self) if block_given?
200
198
  self
@@ -42,9 +42,41 @@ module Infostrada
42
42
  # These action codes are documented on the Infostrada ADVANCED PROGRAMMING documentation
43
43
  attr_accessor :action_code, :action_code_2, :action_code_3
44
44
 
45
- def initialize(match_id, hash)
46
- @match_id = match_id
45
+ def self.from_json(hash = {})
46
+ self.new do |event|
47
+ event.match_id = hash['match_id']
48
+ event.id = hash['id']
49
+ event.description = hash['description']
50
+ event.short_description = hash['short_description']
51
+ event.period = hash['period']
52
+ event.period_short = hash['period_short']
53
+ event.period_code = hash['period_code']
54
+ event.time = hash['time']
55
+ event.home_goals = hash['home_goals']
56
+ event.away_goals = hash['away_goals']
57
+ event.home_event = hash['home_event']
58
+ event.team_id = hash['team_id']
59
+ event.team_name = hash['team_name']
60
+ event.team_short_name = hash['team_short_name']
61
+ event.person_id = hash['person_id']
62
+ event.person_name = hash['person_name']
63
+ event.person_short_name = hash['person_short_name']
64
+ event.reason = hash['reason']
65
+ event.info = hash['info']
66
+ event.person2_id = hash['person2_id']
67
+ event.person2_name = hash['person2_name']
68
+ event.person2_short_name = hash['person2_short_name']
69
+ event.minute = hash['minute']
70
+ event.action_set = hash['action_set']
71
+ event.action_code = hash['action_code']
72
+ event.action_code_2 = hash['action_code_2']
73
+ event.action_code_3 = hash['action_code_3']
74
+ event.action_sort = hash['action_sort']
75
+ end
76
+ end
47
77
 
78
+ def initialize(match_id = nil, hash = {}, &block)
79
+ @match_id = match_id
48
80
  @id = hash['n_ActionID']
49
81
  @description = hash['c_Action']
50
82
  @short_description = hash['c_ActionShort']
@@ -73,6 +105,7 @@ module Infostrada
73
105
  @action_code_3 = hash['n_ActionCode3']
74
106
  @action_sort = hash['n_ActionSort']
75
107
 
108
+ block.call(self) if block_given?
76
109
  self
77
110
  end
78
111
 
@@ -17,7 +17,9 @@ module Infostrada
17
17
  self.new do |table|
18
18
  table.phase_id = json['phase_id']
19
19
  table.edition_id = json['edition_id']
20
- table.entries = json['entries'].map{ |entry| TableEntry.from_json(entry) }
20
+ table.entries = json['entries'].map{ |entry|
21
+ TableEntry.from_json(entry)
22
+ }
21
23
  end
22
24
  end
23
25
 
@@ -27,14 +29,14 @@ module Infostrada
27
29
  @entries = []
28
30
  table_list.each do |hash|
29
31
  @edition_id ||= hash['n_EditionID']
30
- @entries << TableEntry.new(hash)
32
+ @entries << TableEntry.new(hash) if hash['n_TeamID']
31
33
  end
32
34
 
33
35
  block.call(self) if block_given?
34
36
  self
35
37
  end
36
38
 
37
- def as_json(options)
39
+ def as_json(options = {})
38
40
  hash = super
39
41
  hash = { 'phase_id' => phase_id, 'edition_id' => edition_id, 'entries' => hash }
40
42
  end
@@ -1,3 +1,3 @@
1
1
  module Infostrada
2
- VERSION = '0.1.25'
2
+ VERSION = '0.1.26'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infostrada
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.25
4
+ version: 0.1.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Otero
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-09 00:00:00.000000000 Z
11
+ date: 2015-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler