Class: LineScore

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

Overview

This class contains data representing a linescore for a single game.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#away_team_errorsObject

Returns the value of attribute away_team_errors.



6
7
8
# File 'lib/line_score.rb', line 6

def away_team_errors
  @away_team_errors
end

#away_team_hitsObject

Returns the value of attribute away_team_hits.



6
7
8
# File 'lib/line_score.rb', line 6

def away_team_hits
  @away_team_hits
end

#away_team_runsObject

Returns the value of attribute away_team_runs.



6
7
8
# File 'lib/line_score.rb', line 6

def away_team_runs
  @away_team_runs
end

#home_team_errorsObject

Returns the value of attribute home_team_errors.



6
7
8
# File 'lib/line_score.rb', line 6

def home_team_errors
  @home_team_errors
end

#home_team_hitsObject

Returns the value of attribute home_team_hits.



6
7
8
# File 'lib/line_score.rb', line 6

def home_team_hits
  @home_team_hits
end

#home_team_runsObject

Returns the value of attribute home_team_runs.



6
7
8
# File 'lib/line_score.rb', line 6

def home_team_runs
  @home_team_runs
end

#inningsObject

Returns the value of attribute innings.



7
8
9
# File 'lib/line_score.rb', line 7

def innings
  @innings
end

#xml_docObject

Returns the value of attribute xml_doc.



5
6
7
# File 'lib/line_score.rb', line 5

def xml_doc
  @xml_doc
end

Instance Method Details

#init(element) ⇒ Object

Initialize this instance from an XML element containing linescore data.



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/line_score.rb', line 10

def init(element)
	@xml_doc = element
  self.away_team_runs = element.attributes["away_team_runs"]
  self.away_team_hits = element.attributes["away_team_hits"]
  self.away_team_errors = element.attributes["away_team_errors"]
    
  self.home_team_runs = element.attributes["home_team_runs"]
  self.home_team_hits = element.attributes["home_team_hits"]
  self.home_team_errors = element.attributes["home_team_errors"]
  
  # Set score by innings
  set_innings 
end

#set_inningsObject



25
26
27
28
29
30
31
32
33
# File 'lib/line_score.rb', line 25

def set_innings 
  @innings = []
	@xml_doc.elements.each("inning_line_score") do |element|
   score = []
   score.push element.attributes["away"]
   score.push element.attributes["home"]
   @innings.push score
	end
end