Class: GamedayRemoteFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/gameday_remote_fetcher.rb

Class Method Summary collapse

Class Method Details

.fetch(url) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/gameday_remote_fetcher.rb', line 6

def self.fetch(url)
  resp = GamedayUtil.net_http.get_response(URI.parse(url))
  case resp
  when Net::HTTPSuccess
    result = resp.body
  else
    result = nil
  end
  result    
end

.fetch_batter(gid, pid) ⇒ Object

Fetches the batters/(pid).xml file



169
170
171
172
173
174
175
# File 'lib/gameday_remote_fetcher.rb', line 169

def self.fetch_batter(gid, pid)
  gameday_info = GamedayUtil.parse_gameday_id('gid_' + gid)
  url = GamedayUrlBuilder.build_batter_url(gameday_info['year'] , gameday_info['month'], gameday_info['day'] , gid, pid)
  fetch(url)
  #fetcher = CacheFetcher.new()
  #return fetcher.fetch(url)
end

.fetch_batters_page(gid) ⇒ Object

Fetches the HTML page that lists all games for the specified date



227
228
229
230
231
232
# File 'lib/gameday_remote_fetcher.rb', line 227

def self.fetch_batters_page(gid)
  url = GamedayUrlBuilder.build_game_base_url(gid) + '/batters/'
  fetch(url)
  #fetcher = CacheFetcher.new()
  #return fetcher.fetch(url)
end

.fetch_bench(gid) ⇒ Object



40
41
42
43
44
45
# File 'lib/gameday_remote_fetcher.rb', line 40

def self.fetch_bench(gid)
  url = GamedayUrlBuilder.build_game_base_url(gid) + '/bench.xml'
  fetch(url)   
  #fetcher = CacheFetcher.new()
  #return fetcher.fetch(url)
end

.fetch_bencho(gid) ⇒ Object



50
51
52
53
54
55
# File 'lib/gameday_remote_fetcher.rb', line 50

def self.fetch_bencho(gid)
  url = GamedayUrlBuilder.build_game_base_url(gid) + '/benchO.xml'
  fetch(url)
  #fetcher = CacheFetcher.new()
  #return fetcher.fetch(url)
end

.fetch_boxscore(gid) ⇒ Object

Fetches the boxscore.xml file and returns its contents Sample URL: gd2.mlb.com/components/game/mlb/year_2009/month_05/day_08/gid_2009_05_08_detmlb_clemlb_1/boxscore.xml



60
61
62
63
64
65
66
# File 'lib/gameday_remote_fetcher.rb', line 60

def self.fetch_boxscore(gid)
  gameday_info = GamedayUtil.parse_gameday_id('gid_' + gid)
  url = GamedayUrlBuilder.build_boxscore_url(gameday_info['year'] , gameday_info['month'], gameday_info['day'] , gid)
  fetch(url)
  #fetcher = CacheFetcher.new()
  #return fetcher.fetch(url)
end

.fetch_day_highlights(year, month, day) ⇒ Object



32
33
34
35
# File 'lib/gameday_remote_fetcher.rb', line 32

def self.fetch_day_highlights(year, month, day)
  url = GamedayUrlBuilder.build_day_highlights_url(year, month, day)
  fetch(url)
end

.fetch_emailsource(gid) ⇒ Object



71
72
73
74
75
76
# File 'lib/gameday_remote_fetcher.rb', line 71

def self.fetch_emailsource(gid)
  url = GamedayUrlBuilder.build_game_base_url(gid) + '/emailSource.xml'
  fetch(url)
  #fetcher = CacheFetcher.new()
  #return fetcher.fetch(url) 
end

.fetch_epg(year, month, day) ⇒ Object



18
19
20
21
# File 'lib/gameday_remote_fetcher.rb', line 18

def self.fetch_epg(year, month, day)
  url = GamedayUrlBuilder.build_epg_url(year, month, day)
  fetch(url)
end

.fetch_eventlog(gid) ⇒ Object

Fetches the eventLog.xml file and returns its contents Sample URL: gd2.mlb.com/components/game/mlb/year_2008/month_04/day_07/gid_2008_04_07_flomlb_wasmlb_1/eventLog.xml



81
82
83
84
85
# File 'lib/gameday_remote_fetcher.rb', line 81

def self.fetch_eventlog(gid)
  gameday_info = GamedayUtil.parse_gameday_id('gid_' + gid)
  url = GamedayUrlBuilder.build_eventlog_url(gameday_info['year'] , gameday_info['month'], gameday_info['day'] , gid)
  fetch(url)
end

.fetch_game_events(gid) ⇒ Object



98
99
100
101
102
103
104
# File 'lib/gameday_remote_fetcher.rb', line 98

def self.fetch_game_events(gid)
  gameday_info = GamedayUtil.parse_gameday_id('gid_' + gid)
  url = GamedayUrlBuilder.build_game_events_url(gameday_info['year'] , gameday_info['month'], gameday_info['day'] , gid)
  fetch(url)
  #fetcher = CacheFetcher.new()
  #return fetcher.fetch(url)
end

.fetch_game_xml(gid) ⇒ Object

Fetches the game.xml file and returns its contents



89
90
91
92
93
94
95
# File 'lib/gameday_remote_fetcher.rb', line 89

def self.fetch_game_xml(gid)
  gameday_info = GamedayUtil.parse_gameday_id('gid_' + gid)
  url = GamedayUrlBuilder.build_game_url(gameday_info['year'] , gameday_info['month'], gameday_info['day'] , gid)
  fetch(url)
  #fetcher = CacheFetcher.new()
  #return fetcher.fetch(url)
end

.fetch_gamecenter_xml(gid) ⇒ Object

Fetches the gamecenter.xml file and returns its contents



108
109
110
111
112
113
114
# File 'lib/gameday_remote_fetcher.rb', line 108

def self.fetch_gamecenter_xml(gid)
  gameday_info = GamedayUtil.parse_gameday_id('gid_' + gid)
  url = GamedayUrlBuilder.build_gamecenter_url(gameday_info['year'] , gameday_info['month'], gameday_info['day'] , gid)
  fetch(url)
  #fetcher = CacheFetcher.new()
  #return fetcher.fetch(url)
end

.fetch_gamedaysyn(gid) ⇒ Object



119
120
121
122
123
124
# File 'lib/gameday_remote_fetcher.rb', line 119

def self.fetch_gamedaysyn(gid)
  url = GamedayUrlBuilder.build_game_base_url(gid) + '/gameday_Syn.xml'
  fetch(url)
  #fetcher = CacheFetcher.new()
  #return fetcher.fetch(url)    
end

.fetch_games_page(year, month, day) ⇒ Object

Fetches the HTML page that lists all games for the specified date



218
219
220
221
222
223
# File 'lib/gameday_remote_fetcher.rb', line 218

def self.fetch_games_page(year, month, day)
  url = GamedayUrlBuilder.build_day_url(year, month, day)
  fetch(url)
  #fetcher = CacheFetcher.new()
  #return fetcher.fetch(url)
end

.fetch_inning_hit(gid) ⇒ Object

inning/inning_hit.xml



208
209
210
211
212
213
214
# File 'lib/gameday_remote_fetcher.rb', line 208

def self.fetch_inning_hit(gid)
  gameday_info = GamedayUtil.parse_gameday_id('gid_' + gid)
  url = GamedayUrlBuilder.build_inning_hit_url(gameday_info['year'] , gameday_info['month'], gameday_info['day'] , gid)
  fetch(url)
  #fetcher = CacheFetcher.new()
  #return fetcher.fetch(url)
end

.fetch_inning_scores(gid) ⇒ Object

inning/inning_Score.xml



198
199
200
201
202
203
204
# File 'lib/gameday_remote_fetcher.rb', line 198

def self.fetch_inning_scores(gid) 
  gameday_info = GamedayUtil.parse_gameday_id('gid_' + gid)
  url = GamedayUrlBuilder.build_inning_scores_url(gameday_info['year'] , gameday_info['month'], gameday_info['day'] , gid)
  fetch(url)
  #fetcher = CacheFetcher.new()
  #return fetcher.fetch(url)
end

.fetch_inningx(gid, inning_num) ⇒ Object

inning/inning_X.xml



188
189
190
191
192
193
194
# File 'lib/gameday_remote_fetcher.rb', line 188

def self.fetch_inningx(gid, inning_num)
  gameday_info = GamedayUtil.parse_gameday_id('gid_' + gid)
  url = GamedayUrlBuilder.build_inningx_url(gameday_info['year'] , gameday_info['month'], gameday_info['day'] , gid, inning_num)
  fetch(url)
  #fetcher = CacheFetcher.new()
  #return fetcher.fetch(url)
end

.fetch_linescore(gid) ⇒ Object



129
130
131
132
133
134
135
# File 'lib/gameday_remote_fetcher.rb', line 129

def self.fetch_linescore(gid)
  gameday_info = GamedayUtil.parse_gameday_id('gid_' + gid)
  url = GamedayUrlBuilder.build_linescore_url(gameday_info['year'] , gameday_info['month'], gameday_info['day'] , gid)
  fetch(url)
  #fetcher = CacheFetcher.new()
  #return fetcher.fetch(url)
end

.fetch_media_highlights(gid) ⇒ Object



244
245
246
247
248
249
# File 'lib/gameday_remote_fetcher.rb', line 244

def self.fetch_media_highlights(gid)
  url = GamedayUrlBuilder.build_game_base_url(gid) + '/media/highlights.xml'
  fetch(url)
  #fetcher = CacheFetcher.new()
  #return fetcher.fetch(url)
end

.fetch_media_mobile(gid) ⇒ Object



252
253
254
255
256
257
# File 'lib/gameday_remote_fetcher.rb', line 252

def self.fetch_media_mobile(gid)
  url = GamedayUrlBuilder.build_game_base_url(gid) + '/media/mobile.xml'
  fetch(url)
  #fetcher = CacheFetcher.new()
  #return fetcher.fetch(url)
end

.fetch_miniscoreboard(gid) ⇒ Object



140
141
142
143
144
145
# File 'lib/gameday_remote_fetcher.rb', line 140

def self.fetch_miniscoreboard(gid)
  url = GamedayUrlBuilder.build_game_base_url(gid) + '/miniscoreboard.xml'
  fetch(url)
  #fetcher = CacheFetcher.new()
  #return fetcher.fetch(url)   
end

.fetch_notifications_full(gid) ⇒ Object



284
285
286
287
288
289
# File 'lib/gameday_remote_fetcher.rb', line 284

def self.fetch_notifications_full(gid)
  url = GamedayUrlBuilder.build_game_base_url(gid) + "/notifications/notifications_full.xml"
  fetch(url)
  #fetcher = CacheFetcher.new()
  #return fetcher.fetch(url)
end

.fetch_notifications_inning(gid, inning) ⇒ Object



276
277
278
279
280
281
# File 'lib/gameday_remote_fetcher.rb', line 276

def self.fetch_notifications_inning(gid, inning)
  url = GamedayUrlBuilder.build_game_base_url(gid) + "/notifications/notifications_#{inning}.xml"
  fetch(url)
  #fetcher = CacheFetcher.new()
  #return fetcher.fetch(url)
end

.fetch_onbase_linescore(gid) ⇒ Object



260
261
262
263
264
265
# File 'lib/gameday_remote_fetcher.rb', line 260

def self.fetch_onbase_linescore(gid)
  url = GamedayUrlBuilder.build_game_base_url(gid) + '/onbase/linescore.xml'
  fetch(url)
  #fetcher = CacheFetcher.new()
  #return fetcher.fetch(url)
end

.fetch_onbase_plays(gid) ⇒ Object



268
269
270
271
272
273
# File 'lib/gameday_remote_fetcher.rb', line 268

def self.fetch_onbase_plays(gid)
  url = GamedayUrlBuilder.build_game_base_url(gid) + '/onbase/plays.xml'
  fetch(url)
  #fetcher = CacheFetcher.new()
  #return fetcher.fetch(url)
end

.fetch_pitcher(gid, pid) ⇒ Object

Fetches the pitchers/(pid).xml file



179
180
181
182
183
184
185
# File 'lib/gameday_remote_fetcher.rb', line 179

def self.fetch_pitcher(gid, pid)
  gameday_info = GamedayUtil.parse_gameday_id('gid_' + gid)
  url = GamedayUrlBuilder.build_pitcher_url(gameday_info['year'] , gameday_info['month'], gameday_info['day'] , gid, pid)
  fetch(url)
  #fetcher = CacheFetcher.new()
  #return fetcher.fetch(url)
end

.fetch_pitchers_page(gid) ⇒ Object

Fetches the HTML page that lists all games for the specified date



236
237
238
239
240
241
# File 'lib/gameday_remote_fetcher.rb', line 236

def self.fetch_pitchers_page(gid)
  url = GamedayUrlBuilder.build_game_base_url(gid) + '/pitchers/'
  fetch(url)
  #fetcher = CacheFetcher.new()
  #return fetcher.fetch(url)
end

.fetch_players(gid) ⇒ Object

Fetches the players.xml file and returns its contents



149
150
151
152
153
154
155
# File 'lib/gameday_remote_fetcher.rb', line 149

def self.fetch_players(gid)
  gameday_info = GamedayUtil.parse_gameday_id('gid_' + gid)
  url = GamedayUrlBuilder.build_players_url(gameday_info['year'] , gameday_info['month'], gameday_info['day'] , gid)
  fetch(url)
  #fetcher = CacheFetcher.new()
  #return fetcher.fetch(url)
end

.fetch_plays(gid) ⇒ Object



160
161
162
163
164
165
# File 'lib/gameday_remote_fetcher.rb', line 160

def self.fetch_plays(gid)
  url = GamedayUrlBuilder.build_game_base_url(gid) + '/plays.xml'
  fetch(url)
  #fetcher = CacheFetcher.new()
  #return fetcher.fetch(url)
end

.fetch_scoreboard(year, month, day) ⇒ Object



26
27
28
29
# File 'lib/gameday_remote_fetcher.rb', line 26

def self.fetch_scoreboard(year, month, day)
  url = GamedayUrlBuilder.build_scoreboard_url(year, month, day)
  fetch(url)
end