Class: Inning
- Inherits:
-
Object
- Object
- Inning
- Defined in:
- lib/inning.rb
Overview
This class represents a single inning of an MLB game
Instance Attribute Summary collapse
-
#away_team ⇒ Object
Returns the value of attribute away_team.
-
#bottom_atbats ⇒ Object
Returns the value of attribute bottom_atbats.
-
#gid ⇒ Object
Returns the value of attribute gid.
-
#home_team ⇒ Object
Returns the value of attribute home_team.
-
#num ⇒ Object
Returns the value of attribute num.
-
#top_atbats ⇒ Object
Returns the value of attribute top_atbats.
Instance Method Summary collapse
-
#load_from_id(gid, inning) ⇒ Object
loads an Inning object given a game id and an inning number.
Instance Attribute Details
#away_team ⇒ Object
Returns the value of attribute away_team.
8 9 10 |
# File 'lib/inning.rb', line 8 def away_team @away_team end |
#bottom_atbats ⇒ Object
Returns the value of attribute bottom_atbats.
8 9 10 |
# File 'lib/inning.rb', line 8 def bottom_atbats @bottom_atbats end |
#gid ⇒ Object
Returns the value of attribute gid.
8 9 10 |
# File 'lib/inning.rb', line 8 def gid @gid end |
#home_team ⇒ Object
Returns the value of attribute home_team.
8 9 10 |
# File 'lib/inning.rb', line 8 def home_team @home_team end |
#num ⇒ Object
Returns the value of attribute num.
8 9 10 |
# File 'lib/inning.rb', line 8 def num @num end |
#top_atbats ⇒ Object
Returns the value of attribute top_atbats.
8 9 10 |
# File 'lib/inning.rb', line 8 def top_atbats @top_atbats end |
Instance Method Details
#load_from_id(gid, inning) ⇒ Object
loads an Inning object given a game id and an inning number
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/inning.rb', line 12 def load_from_id(gid, inning) @top_atbats = [] @bottom_atbats = [] @gid = gid begin @xml_data = GamedayFetcher.fetch_inningx(gid, inning) @xml_doc = REXML::Document.new(@xml_data) if @xml_doc.root @num = @xml_doc.root.attributes["num"] @away_team = @xml_doc.root.attributes["away_team"] @home_team = @xml_doc.root.attributes["home_team"] set_top_ab set_bottom_ab end rescue puts "Could not load inning file for #{gid}, inning #{inning.to_s}" end end |