Class: AtBat
- Inherits:
-
Object
- Object
- AtBat
- Defined in:
- lib/at_bat.rb
Overview
This class represents a single atbat during a single game
Instance Attribute Summary collapse
-
#away_team ⇒ Object
Returns the value of attribute away_team.
-
#b ⇒ Object
Returns the value of attribute b.
-
#b_height ⇒ Object
Returns the value of attribute b_height.
-
#batter_id ⇒ Object
Returns the value of attribute batter_id.
-
#des ⇒ Object
Returns the value of attribute des.
-
#event ⇒ Object
Returns the value of attribute event.
-
#gid ⇒ Object
Returns the value of attribute gid.
-
#home_team ⇒ Object
Returns the value of attribute home_team.
-
#inning ⇒ Object
Returns the value of attribute inning.
-
#num ⇒ Object
Returns the value of attribute num.
-
#o ⇒ Object
Returns the value of attribute o.
-
#p_throws ⇒ Object
Returns the value of attribute p_throws.
-
#pitcher_id ⇒ Object
Returns the value of attribute pitcher_id.
-
#pitches ⇒ Object
Returns the value of attribute pitches.
-
#s ⇒ Object
Returns the value of attribute s.
-
#stand ⇒ Object
Returns the value of attribute stand.
Instance Method Summary collapse
Instance Attribute Details
#away_team ⇒ Object
Returns the value of attribute away_team.
7 8 9 |
# File 'lib/at_bat.rb', line 7 def away_team @away_team end |
#b ⇒ Object
Returns the value of attribute b.
8 9 10 |
# File 'lib/at_bat.rb', line 8 def b @b end |
#b_height ⇒ Object
Returns the value of attribute b_height.
8 9 10 |
# File 'lib/at_bat.rb', line 8 def b_height @b_height end |
#batter_id ⇒ Object
Returns the value of attribute batter_id.
8 9 10 |
# File 'lib/at_bat.rb', line 8 def batter_id @batter_id end |
#des ⇒ Object
Returns the value of attribute des.
8 9 10 |
# File 'lib/at_bat.rb', line 8 def des @des end |
#event ⇒ Object
Returns the value of attribute event.
8 9 10 |
# File 'lib/at_bat.rb', line 8 def event @event end |
#gid ⇒ Object
Returns the value of attribute gid.
7 8 9 |
# File 'lib/at_bat.rb', line 7 def gid @gid end |
#home_team ⇒ Object
Returns the value of attribute home_team.
7 8 9 |
# File 'lib/at_bat.rb', line 7 def home_team @home_team end |
#inning ⇒ Object
Returns the value of attribute inning.
7 8 9 |
# File 'lib/at_bat.rb', line 7 def inning @inning end |
#num ⇒ Object
Returns the value of attribute num.
8 9 10 |
# File 'lib/at_bat.rb', line 8 def num @num end |
#o ⇒ Object
Returns the value of attribute o.
8 9 10 |
# File 'lib/at_bat.rb', line 8 def o @o end |
#p_throws ⇒ Object
Returns the value of attribute p_throws.
8 9 10 |
# File 'lib/at_bat.rb', line 8 def p_throws @p_throws end |
#pitcher_id ⇒ Object
Returns the value of attribute pitcher_id.
8 9 10 |
# File 'lib/at_bat.rb', line 8 def pitcher_id @pitcher_id end |
#pitches ⇒ Object
Returns the value of attribute pitches.
9 10 11 |
# File 'lib/at_bat.rb', line 9 def pitches @pitches end |
#s ⇒ Object
Returns the value of attribute s.
8 9 10 |
# File 'lib/at_bat.rb', line 8 def s @s end |
#stand ⇒ Object
Returns the value of attribute stand.
8 9 10 |
# File 'lib/at_bat.rb', line 8 def stand @stand end |
Instance Method Details
#init(element, gid, inning) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/at_bat.rb', line 11 def init(element, gid, inning) @inning = inning @xml_doc = element @gid = gid @num = element.attributes["num"] @b = element.attributes["b"] @s = element.attributes["s"] @o = element.attributes["o"] @batter_id = element.attributes["batter"] @stand = element.attributes["stand"] @b_height = element.attributes["b_height"] @pitcher_id = element.attributes["pitcher"] @p_throws = element.attributes["p_throws"] @des = element.attributes["des"] @event = element.attributes["event"] set_pitches(element) end |
#set_pitches(element) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/at_bat.rb', line 30 def set_pitches(element) @pitches = [] element.elements.each("pitch") do |element| pitch = Pitch.new pitch.init(element) @pitches << pitch end end |