Class: Game

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

Overview

This class represents a single MLB game

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gid) ⇒ Game

Returns a new instance of Game.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/game.rb', line 36

def initialize(gid)
  @innings = []
  team = Team.new('')
  if gid
    @gid = gid     
    @xml_data = GamedayFetcher.fetch_game_xml(gid)
    if @xml_data && @xml_data.size > 0
      @xml_doc = REXML::Document.new(@xml_data)
      @game_type = @xml_doc.root.attributes["type"]
      @time = @xml_doc.root.attributes["local_game_time"]     
      info = GamedayUtil.parse_gameday_id('gid_'+gid)
      @home_team_abbrev = info["home_team_abbrev"]
      @visit_team_abbrev = info["visiting_team_abbrev"]
      @visiting_team = Team.new(@visit_team_abbrev )
      @home_team = Team.new(@home_team_abbrev )
      @year = info["year"]
      @month = info["month"]
      @day = info["day"]
      @game_number = info["game_number"]
      if Team.teams[@home_team_abbrev]
        @home_team_name = Team.teams[@home_team_abbrev][0]
      else
        @home_team_name = @home_team_abbrev
      end
      if Team.teams[@visit_team_abbrev]
        @visit_team_name = Team.teams[@visit_team_abbrev][0]
      else
        @visit_team_name = @visit_team_abbrev
      end
    else
      raise ArgumentError, "Could not find game.xml"
    end
  end
end

Instance Attribute Details

#ampmObject

additional attributes from master_scoreboard.xml



23
24
25
# File 'lib/game.rb', line 23

def ampm
  @ampm
end

#away_codeObject

Returns the value of attribute away_code.



24
25
26
# File 'lib/game.rb', line 24

def away_code
  @away_code
end

#away_divisionObject

Returns the value of attribute away_division.



25
26
27
# File 'lib/game.rb', line 25

def away_division
  @away_division
end

#away_errorsObject

Returns the value of attribute away_errors.



34
35
36
# File 'lib/game.rb', line 34

def away_errors
  @away_errors
end

#away_file_codeObject

Returns the value of attribute away_file_code.



24
25
26
# File 'lib/game.rb', line 24

def away_file_code
  @away_file_code
end

#away_games_backObject

Returns the value of attribute away_games_back.



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

def away_games_back
  @away_games_back
end

#away_games_back_wildcardObject

Returns the value of attribute away_games_back_wildcard.



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

def away_games_back_wildcard
  @away_games_back_wildcard
end

#away_hitsObject

Returns the value of attribute away_hits.



34
35
36
# File 'lib/game.rb', line 34

def away_hits
  @away_hits
end

#away_inningsObject

An arry of one element for each inning, the element is the home or away score



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

def away_innings
  @away_innings
end

#away_lossObject

Returns the value of attribute away_loss.



28
29
30
# File 'lib/game.rb', line 28

def away_loss
  @away_loss
end

#away_name_abbrevObject

Returns the value of attribute away_name_abbrev.



24
25
26
# File 'lib/game.rb', line 24

def away_name_abbrev
  @away_name_abbrev
end

#away_runsObject

Returns the value of attribute away_runs.



34
35
36
# File 'lib/game.rb', line 34

def away_runs
  @away_runs
end

#away_team_cityObject

Returns the value of attribute away_team_city.



25
26
27
# File 'lib/game.rb', line 25

def away_team_city
  @away_team_city
end

#away_team_idObject

Returns the value of attribute away_team_id.



24
25
26
# File 'lib/game.rb', line 24

def away_team_id
  @away_team_id
end

#away_team_nameObject

Returns the value of attribute away_team_name.



25
26
27
# File 'lib/game.rb', line 25

def away_team_name
  @away_team_name
end

#away_winObject

Returns the value of attribute away_win.



28
29
30
# File 'lib/game.rb', line 28

def away_win
  @away_win
end

#boxscoreObject

Returns the value of attribute boxscore.



16
17
18
# File 'lib/game.rb', line 16

def boxscore
  @boxscore
end

#dateObject

Returns the value of attribute date.



16
17
18
# File 'lib/game.rb', line 16

def date
  @date
end

#dayObject

Returns the value of attribute day.



14
15
16
# File 'lib/game.rb', line 14

def day
  @day
end

#eventlogObject

Returns the value of attribute eventlog.



16
17
18
# File 'lib/game.rb', line 16

def eventlog
  @eventlog
end

#game_numberObject

Returns the value of attribute game_number.



14
15
16
# File 'lib/game.rb', line 14

def game_number
  @game_number
end

#game_pkObject

additional attributes from master_scoreboard.xml



23
24
25
# File 'lib/game.rb', line 23

def game_pk
  @game_pk
end

#game_typeObject

additional attributes from master_scoreboard.xml



23
24
25
# File 'lib/game.rb', line 23

def game_type
  @game_type
end

#gamedayObject

Returns the value of attribute gameday.



28
29
30
# File 'lib/game.rb', line 28

def gameday
  @gameday
end

#gameday_swObject

Returns the value of attribute gameday_sw.



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

def gameday_sw
  @gameday_sw
end

#gidObject

Returns the value of attribute gid.



14
15
16
# File 'lib/game.rb', line 14

def gid
  @gid
end

#home_codeObject

Returns the value of attribute home_code.



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

def home_code
  @home_code
end

#home_divisionObject

Returns the value of attribute home_division.



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

def home_division
  @home_division
end

#home_errorsObject

Returns the value of attribute home_errors.



34
35
36
# File 'lib/game.rb', line 34

def home_errors
  @home_errors
end

#home_file_codeObject

Returns the value of attribute home_file_code.



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

def home_file_code
  @home_file_code
end

#home_games_backObject

Returns the value of attribute home_games_back.



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

def home_games_back
  @home_games_back
end

#home_games_back_wildcardObject

Returns the value of attribute home_games_back_wildcard.



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

def home_games_back_wildcard
  @home_games_back_wildcard
end

#home_hitsObject

Returns the value of attribute home_hits.



34
35
36
# File 'lib/game.rb', line 34

def home_hits
  @home_hits
end

#home_inningsObject

An arry of one element for each inning, the element is the home or away score



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

def home_innings
  @home_innings
end

#home_lossObject

Returns the value of attribute home_loss.



28
29
30
# File 'lib/game.rb', line 28

def home_loss
  @home_loss
end

#home_name_abbrevObject

Returns the value of attribute home_name_abbrev.



24
25
26
# File 'lib/game.rb', line 24

def home_name_abbrev
  @home_name_abbrev
end

#home_runsObject

Returns the value of attribute home_runs.



34
35
36
# File 'lib/game.rb', line 34

def home_runs
  @home_runs
end

#home_teamObject

Returns the value of attribute home_team.



14
15
16
# File 'lib/game.rb', line 14

def home_team
  @home_team
end

#home_team_abbrevObject

Returns the value of attribute home_team_abbrev.



14
15
16
# File 'lib/game.rb', line 14

def home_team_abbrev
  @home_team_abbrev
end

#home_team_cityObject

Returns the value of attribute home_team_city.



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

def home_team_city
  @home_team_city
end

#home_team_idObject

Returns the value of attribute home_team_id.



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

def home_team_id
  @home_team_id
end

#home_team_nameObject

Returns the value of attribute home_team_name.



14
15
16
# File 'lib/game.rb', line 14

def home_team_name
  @home_team_name
end

#home_winObject

Returns the value of attribute home_win.



28
29
30
# File 'lib/game.rb', line 28

def home_win
  @home_win
end

#homerunsObject

an array of players with homeruns in the game



31
32
33
# File 'lib/game.rb', line 31

def homeruns
  @homeruns
end

#inningsObject

array of Inning objects, from innings files



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

def innings
  @innings
end

#leagueObject

Returns the value of attribute league.



28
29
30
# File 'lib/game.rb', line 28

def league
  @league
end

#losing_pitcherObject

Instances of Player object



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

def losing_pitcher
  @losing_pitcher
end

#mediaObject

Returns the value of attribute media.



16
17
18
# File 'lib/game.rb', line 16

def media
  @media
end

#monthObject

Returns the value of attribute month.



14
15
16
# File 'lib/game.rb', line 14

def month
  @month
end

#playersObject

data from the players.xml file



20
21
22
# File 'lib/game.rb', line 20

def players
  @players
end

#rostersObject

Returns the value of attribute rosters.



16
17
18
# File 'lib/game.rb', line 16

def rosters
  @rosters
end

#save_pitcherObject

Instances of Player object



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

def save_pitcher
  @save_pitcher
end

#scoreboard_game_idObject

additional attributes from master_scoreboard.xml



23
24
25
# File 'lib/game.rb', line 23

def scoreboard_game_id
  @scoreboard_game_id
end

#statusObject

An instance of GameStatus object



30
31
32
# File 'lib/game.rb', line 30

def status
  @status
end

#timeObject

additional attributes from master_scoreboard.xml



23
24
25
# File 'lib/game.rb', line 23

def time
  @time
end

#time_zoneObject

additional attributes from master_scoreboard.xml



23
24
25
# File 'lib/game.rb', line 23

def time_zone
  @time_zone
end

#venueObject

additional attributes from master_scoreboard.xml



23
24
25
# File 'lib/game.rb', line 23

def venue
  @venue
end

#venue_w_chan_locObject

Returns the value of attribute venue_w_chan_loc.



28
29
30
# File 'lib/game.rb', line 28

def venue_w_chan_loc
  @venue_w_chan_loc
end

#visit_team_abbrevObject

Returns the value of attribute visit_team_abbrev.



14
15
16
# File 'lib/game.rb', line 14

def visit_team_abbrev
  @visit_team_abbrev
end

#visit_team_nameObject

Returns the value of attribute visit_team_name.



14
15
16
# File 'lib/game.rb', line 14

def visit_team_name
  @visit_team_name
end

#visiting_teamObject

Returns the value of attribute visiting_team.



14
15
16
# File 'lib/game.rb', line 14

def visiting_team
  @visiting_team
end

#winning_pitcherObject

Instances of Player object



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

def winning_pitcher
  @winning_pitcher
end

#yearObject

Returns the value of attribute year.



14
15
16
# File 'lib/game.rb', line 14

def year
  @year
end

Class Method Details

.find_by_date(year, month, day) ⇒ Object

Returns an array of Game objects for each game for the specified day



207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/game.rb', line 207

def self.find_by_date(year, month, day)
  begin 
    games = []
    games_page = GamedayFetcher.fetch_games_page(year, month, day)
    if games_page
      @hp = Hpricot(games_page) 
      a = @hp.at('ul')  
      (a/"a").each do |link|
        # look at each link inside of a ul tag
        if link.inner_html.include?('gid')
          # if the link contains the text 'gid' then it is a listing of a game
          str = link.inner_html
          gid = str[5..str.length-2]
          begin
            game = Game.new(gid)
            games.push game
          rescue
            puts "Could not create game object for #{year}, #{month}, #{day} - #{gid}"
          end
        end
      end
    else
      puts "Could not read games page for #{year}, #{month}, #{day}."
    end
    return games
  rescue
    puts "No games data found for #{year}, #{month}, #{day}."
  end
end

.find_by_month(year, month) ⇒ Object



195
196
197
198
199
200
201
202
203
# File 'lib/game.rb', line 195

def self.find_by_month(year, month)
  games = []
  start_date = Date.new(year.to_i, month.to_i) # first day of month
  end_date = (start_date >> 1)-1 # last day of month
  ((start_date)..(end_date)).each do |dt| 
    games += find_by_date(year, month, dt.day.to_s)
  end
  games
end

Instance Method Details

#dump_boxscoreObject

Saves an HTML version of the boxscore for the game



272
273
274
275
276
277
278
279
# File 'lib/game.rb', line 272

def dump_boxscore
  if self.gid
    bs = get_boxscore
    GamedayUtil.save_file("boxscore.html", bs.to_html('boxscore.html.erb'))
  else
    puts "No data for input specified"
  end
end

#get_atbatsObject

Returns an array of AtBat objects that represent each atbat of the game



441
442
443
444
445
446
447
448
449
450
451
452
453
# File 'lib/game.rb', line 441

def get_atbats
  atbats = []
  innings = get_innings
  innings.each do |inning|
    inning.top_atbats.each do |atbat|
      atbats << atbat
    end
    inning.bottom_atbats.each do |atbat|
      atbats << atbat
    end
  end
  atbats
end

#get_attendanceObject

Returns a string holding the game attendance value



410
411
412
413
414
# File 'lib/game.rb', line 410

def get_attendance
  game_info = get_boxscore.game_info
  # parse game_info to get attendance
  game_info[game_info.length-12..game_info.length-7]
end

#get_away_runsObject



522
523
524
525
# File 'lib/game.rb', line 522

def get_away_runs
  bs = get_boxscore
  bs.away_runs
end

#get_batters(home_or_away) ⇒ Object

Returns an array of either home or away batters for this game home_or_away must be a string with value ‘home’ or ‘away’ The values in the returned array are BattingAppearance instances



352
353
354
355
356
357
358
359
360
361
362
363
# File 'lib/game.rb', line 352

def get_batters(home_or_away)
  if self.gid
    bs = get_boxscore
    if home_or_away == 'away'
    	bs.batters[0]
    else
      bs.batters[1]
    end
  else
    puts "No data for input specified"
  end
end

#get_boxscoreObject

Returns a BoxScore object representing the boxscore for this game



261
262
263
264
265
266
267
268
# File 'lib/game.rb', line 261

def get_boxscore
  if !@boxscore
    box = BoxScore.new
    box.load_from_id(self.gid)
    @boxscore = box
  end
  @boxscore
end

#get_closing_pitchersObject

Returns an array of the closing pitchers for the game

[0] = visiting team pitcher
[1] = home team pitcher


311
312
313
314
315
316
317
# File 'lib/game.rb', line 311

def get_closing_pitchers
  results = []
  away_pitchers = get_pitchers('away')
  home_pitchers = get_pitchers('home')
  results << away_pitchers[(away_pitchers.size) - 1]
  results << home_pitchers[(home_pitchers.size) -1]
end

#get_dateObject



492
493
494
495
# File 'lib/game.rb', line 492

def get_date
  bs = get_boxscore
  bs.date
end

#get_eventlogObject



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

def get_eventlog
  if !@eventlog
    @eventlog = EventLog.new
    @eventlog.load_from_id(@gid)
  end
  @eventlog
end

#get_hitchartObject



456
457
458
459
460
461
462
# File 'lib/game.rb', line 456

def get_hitchart
  if !@hitchart
    @hitchart = Hitchart.new
    @hitchart.load_from_gid(@gid)
  end
  @hitchart
end

#get_home_runsObject



516
517
518
519
# File 'lib/game.rb', line 516

def get_home_runs
  bs = get_boxscore
  bs.home_runs
end

#get_inningsObject

Returns an array of Inning objects that represent each inning of the game



427
428
429
430
431
432
433
434
435
436
437
# File 'lib/game.rb', line 427

def get_innings
  if @innings.length == 0
    inn_count = get_num_innings
    (1..get_num_innings).each do |inn|
      inning = Inning.new
      inning.load_from_id(@gid, inn)
      @innings << inning
    end
  end
  @innings
end

#get_lineupsObject

Returns the starting lineups for this game in an array with 2 elements results = visitors results = home



369
370
371
372
373
# File 'lib/game.rb', line 369

def get_lineups
  results = []
  results << get_batters('away')
  results << get_batters('home')
end

#get_mediaObject



417
418
419
420
421
422
423
# File 'lib/game.rb', line 417

def get_media
  if !@media
    @media = Media.new
    @media.load_from_id(@gid) 
  end
  @media
end

#get_num_inningsObject

Returns the number of innings for this game



466
467
468
469
470
471
472
473
# File 'lib/game.rb', line 466

def get_num_innings
  bs = get_boxscore
  if bs.linescore
    return get_boxscore.linescore.innings.length
  else
    return 0
  end
end

#get_pitchers(home_or_away) ⇒ Object

Returns an array of all pitchers for either the home team or the away team. The values in the returned array are PitchingAppearance instances



322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/game.rb', line 322

def get_pitchers(home_or_away)
  if self.gid
    bs = get_boxscore
    if home_or_away == 'away'
      bs.pitchers[0]
    else
      bs.pitchers[1]
    end
  else
    puts "No data for input specified"
  end
end

#get_pitches(pid) ⇒ Object

Returns an array of pitches from this game for the pitcher identified by pid



337
338
339
340
341
342
343
344
345
346
# File 'lib/game.rb', line 337

def get_pitches(pid)
  results = []
  atbats = get_atbats
  atbats.each do |ab|
    if ab.pitcher_id == pid
      results << ab.pitches
    end
  end
  results.flatten
end

#get_pitchingObject

Returns the pitchers for this game in an array with 2 elements results = visitors results = home



379
380
381
382
383
# File 'lib/game.rb', line 379

def get_pitching
  results = []
  results << get_pitchers('away')
  results << get_pitchers('home')
end

#get_rostersObject

Returns a 2 element array containing the home and visiting rosters for this game

[0] array of all visitor players
[1] array of all home players


241
242
243
244
245
246
247
248
# File 'lib/game.rb', line 241

def get_rosters
  if !@rosters
    players = Players.new
    players.load_from_id(@gid)
    @rosters = players.rosters
  end
  @rosters
end

#get_scoreObject

Returns a 2 element array holding the game score

[0] visiting team runs
[1] home team runs


400
401
402
403
404
405
406
# File 'lib/game.rb', line 400

def get_score
  results = []
  ls = get_boxscore.linescore
  results << ls.away_team_runs
  results << ls.home_team_runs
  results
end

#get_starting_pitchersObject

Returns an array of the starting pitchers for the game

[0] = visiting team pitcher
[1] = home team pitcher


301
302
303
304
305
# File 'lib/game.rb', line 301

def get_starting_pitchers
  results = []
  results << get_pitchers('away')[0]
  results << get_pitchers('home')[0]
end

#get_tempObject



498
499
500
501
# File 'lib/game.rb', line 498

def get_temp
  bs = get_boxscore
  bs.temp
end

#get_umpiresObject

Returns a hash of umpires for this game

{ 'hp' => 'john doe',
  '1b' => 'paul jones',
  '2b' => 'mike james',
  '3b' => 'pete myers' }


483
484
485
486
487
488
489
# File 'lib/game.rb', line 483

def get_umpires
  if !@players
    @players = Players.new
    @players.load_from_id(@gid)
  end
  @players.umpires
end

#get_wind_dirObject



510
511
512
513
# File 'lib/game.rb', line 510

def get_wind_dir
  bs = get_boxscore 
  bs.wind_dir
end

#get_wind_speedObject



504
505
506
507
# File 'lib/game.rb', line 504

def get_wind_speed
  bs = get_boxscore
  bs.wind_speed
end

#get_winnerObject

Returns the team abreviation of the winning team



387
388
389
390
391
392
393
394
# File 'lib/game.rb', line 387

def get_winner
  ls = get_boxscore.linescore
  if ls.home_team_runs > ls.away_team_runs
    return home_team_abbrev
  else
    return visit_team_abbrev
  end
end

#load_from_scoreboard(element) ⇒ Object

Setup a Game object from data read from the master_scoreboard.xml file



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/game.rb', line 73

def load_from_scoreboard(element)
  @away_innings = []
  @home_innings = []
  @scoreboard_game_id = element.attributes['id']
  @ampm = element.attributes['ampm']
  @venue = element.attributes['venue']
  @game_pk = element.attributes['game_pk']
  @time = element.attributes['time']
  @time_zone = element.attributes['time_zone']
  @game_type = element.attributes['game_type']
  @away_name_abbrev = element.attributes['away_name_abbrev']
  @home_name_abbrev = element.attributes['home_name_abbrev']
  @away_code = element.attributes['away_code']
  @away_file_code = element.attributes['away_file_code']
  @away_team_id = element.attributes['away_team_id']
  @away_team_city = element.attributes['away_team_city']
  @away_team_name = element.attributes['away_team_name']
  @away_division = element.attributes['away_division']
  @home_code = element.attributes['home_code']
  @home_file_code = element.attributes['home_file_code']
  @home_team_id = element.attributes['home_team_id']
  @home_team_city = element.attributes['home_team_city']
  @home_team_name = element.attributes['home_team_name']
  @home_division = element.attributes['home_division']
  @day = element.attributes['day']
  @gameday_sw = element.attributes['gameday_sw']
  @away_games_back = element.attributes['away_games_back']
  @home_games_back = element.attributes['home_games_back']
  @away_games_back_wildcard = element.attributes['away_games_back_wildcard']
  @home_games_back_wildcard = element.attributes['home_games_back_wildcard']
  @venue_w_chan_loc = element.attributes['venue_w_chan_loc']
  @gameday = element.attributes['gameday']
  @away_win = element.attributes['away_win']
  @away_loss = element.attributes['away_loss']
  @home_win = element.attributes['home_win']
  @home_loss = element.attributes['home_loss']
  @league = element.attributes['league']
  
  set_status(element)
  set_innings(element)
  set_totals(element)
  set_pitchers(element)
  set_homeruns(element)
end

Returns a string containing the linescore in the following printed format:

Away 1 3 1
Home 5 8 0


285
286
287
288
289
290
291
292
293
294
295
# File 'lib/game.rb', line 285

def print_linescore
	bs = get_boxscore
	output = ''
	if bs.linescore 
  	output += self.visit_team_name + ' ' + bs.linescore.away_team_runs + ' ' + bs.linescore.away_team_hits + ' ' + bs.linescore.away_team_errors + "\n"
  	output += self.home_team_name + ' ' + bs.linescore.home_team_runs + ' ' + bs.linescore.home_team_hits + ' ' + bs.linescore.home_team_errors
  else
  	output += 'No linescore available for ' + @visit_team_name + ' vs. ' + @home_team_name
  end
  output
end

#set_homeruns(element) ⇒ Object

Sets a list of players who had homeruns in this game from data in the master_scoreboard.xml file



162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/game.rb', line 162

def set_homeruns(element)
  @homeruns = []
  element.elements.each("home_runs/player") do |hr|
    player = Player.new
    player.last = hr.attributes['last']
    player.first = hr.attributes['first']
    player.hr = hr.attributes['hr']
    player.std_hr = hr.attributes['std_hr']
    player.team_code = hr.attributes['team_code']
    @homeruns << player
  end
end

#set_innings(element) ⇒ Object

Sets the away and home innings array containing scores by inning from data in the master_scoreboard.xml file



136
137
138
139
140
141
# File 'lib/game.rb', line 136

def set_innings(element)
  element.elements.each("linescore/inning") { |element|
     @away_innings << element.attributes['away']
     @home_innings << element.attributes['home']
  }
end

#set_pitchers(element) ⇒ Object

Sets the pitchers of record (win, lose, save) from data in the master_scoreboard.xml file



177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/game.rb', line 177

def set_pitchers(element)
  element.elements.each("winning_pitcher") do |wp|
    @winning_pitcher = Player.new
    @winning_pitcher.init_pitcher_from_scoreboard(wp)
  end
  element.elements.each("losing_pitcher") do |lp|
    @losing_pitcher = Player.new
    @losing_pitcher.init_pitcher_from_scoreboard(lp)
  end
  element.elements.each("save_pitcher") do |sp|
    @save_pitcher = Player.new
    @save_pitcher.first = sp.attributes['first']
    @save_pitcher.last = sp.attributes['last']
    @save_pitcher.saves = sp.attributes['saves']
  end
end

#set_status(element) ⇒ Object

Sets the game status from data in the master_scoreboard.xml file



120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/game.rb', line 120

def set_status(element)
  element.elements.each("status") { |status|
    @status = GameStatus.new
    @status.status = status.attributes['status']
    @status.ind = status.attributes['ind']
    @status.reason = status.attributes['reason']
    @status.inning = status.attributes['inning']
    @status.top_inning = status.attributes['top_inning']
    @status.b = status.attributes['b']
    @status.s = status.attributes['s']
    @status.o = status.attributes['o']
  }
end

#set_totals(element) ⇒ Object

Sets the Runs/Hits/Errors totals from data in the master_scoreboard.xml file



145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/game.rb', line 145

def set_totals(element)
  element.elements.each("linescore/r") { |runs|
     @away_runs = runs.attributes['away']
     @home_runs = runs.attributes['home']
  }
  element.elements.each("linescore/h") { |hits|
     @away_hits = hits.attributes['away']
     @home_hits = hits.attributes['home']
  }
  element.elements.each("linescore/e") { |errs|
     @away_errors = errs.attributes['away']
     @home_errors = errs.attributes['home']
  }
end