Class: AtBat

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

Overview

This class represents a single atbat during a single game

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#away_teamObject

Returns the value of attribute away_team.



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

def away_team
  @away_team
end

#bObject

Returns the value of attribute b.



8
9
10
# File 'lib/at_bat.rb', line 8

def b
  @b
end

#b_heightObject

Returns the value of attribute b_height.



8
9
10
# File 'lib/at_bat.rb', line 8

def b_height
  @b_height
end

#batter_idObject

Returns the value of attribute batter_id.



8
9
10
# File 'lib/at_bat.rb', line 8

def batter_id
  @batter_id
end

#desObject

Returns the value of attribute des.



8
9
10
# File 'lib/at_bat.rb', line 8

def des
  @des
end

#eventObject

Returns the value of attribute event.



8
9
10
# File 'lib/at_bat.rb', line 8

def event
  @event
end

#gidObject

Returns the value of attribute gid.



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

def gid
  @gid
end

#home_teamObject

Returns the value of attribute home_team.



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

def home_team
  @home_team
end

#inningObject

Returns the value of attribute inning.



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

def inning
  @inning
end

#numObject

Returns the value of attribute num.



8
9
10
# File 'lib/at_bat.rb', line 8

def num
  @num
end

#oObject

Returns the value of attribute o.



8
9
10
# File 'lib/at_bat.rb', line 8

def o
  @o
end

#p_throwsObject

Returns the value of attribute p_throws.



8
9
10
# File 'lib/at_bat.rb', line 8

def p_throws
  @p_throws
end

#pitcher_idObject

Returns the value of attribute pitcher_id.



8
9
10
# File 'lib/at_bat.rb', line 8

def pitcher_id
  @pitcher_id
end

#pitchesObject

Returns the value of attribute pitches.



9
10
11
# File 'lib/at_bat.rb', line 9

def pitches
  @pitches
end

#sObject

Returns the value of attribute s.



8
9
10
# File 'lib/at_bat.rb', line 8

def s
  @s
end

#standObject

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