Class: LineScore
- Inherits:
-
Object
- Object
- LineScore
- Defined in:
- lib/line_score.rb
Overview
This class contains data representing a linescore for a single game.
Instance Attribute Summary collapse
-
#away_team_errors ⇒ Object
Returns the value of attribute away_team_errors.
-
#away_team_hits ⇒ Object
Returns the value of attribute away_team_hits.
-
#away_team_runs ⇒ Object
Returns the value of attribute away_team_runs.
-
#home_team_errors ⇒ Object
Returns the value of attribute home_team_errors.
-
#home_team_hits ⇒ Object
Returns the value of attribute home_team_hits.
-
#home_team_runs ⇒ Object
Returns the value of attribute home_team_runs.
-
#innings ⇒ Object
Returns the value of attribute innings.
-
#xml_doc ⇒ Object
Returns the value of attribute xml_doc.
Instance Method Summary collapse
-
#init(element) ⇒ Object
Initialize this instance from an XML element containing linescore data.
- #set_innings ⇒ Object
Instance Attribute Details
#away_team_errors ⇒ Object
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_hits ⇒ Object
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_runs ⇒ Object
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_errors ⇒ Object
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_hits ⇒ Object
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_runs ⇒ Object
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 |
#innings ⇒ Object
Returns the value of attribute innings.
7 8 9 |
# File 'lib/line_score.rb', line 7 def innings @innings end |
#xml_doc ⇒ Object
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_innings ⇒ Object
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 |