Class: Pitch
- Inherits:
-
Object
- Object
- Pitch
- Defined in:
- lib/pitch.rb
Overview
This class represents a single pitch in an MLB baseball game. Most of the attributes represent the physics of the pitch thrown.
Pitch Type Codes
FS = Splitter
SL = Slider
FF = Fastball
SI = Sinker
CH = Change
FA = Fastball
CU = Curve
FC = Cutter
KN = Knuckle
KC = Knuckle Curve
Instance Attribute Summary collapse
-
#ab_num ⇒ Object
Returns the value of attribute ab_num.
-
#ax ⇒ Object
Returns the value of attribute ax.
-
#ay ⇒ Object
Returns the value of attribute ay.
-
#az ⇒ Object
Returns the value of attribute az.
-
#batter_id ⇒ Object
Returns the value of attribute batter_id.
-
#break_angle ⇒ Object
Returns the value of attribute break_angle.
-
#break_length ⇒ Object
Returns the value of attribute break_length.
-
#break_y ⇒ Object
Returns the value of attribute break_y.
-
#des ⇒ Object
Returns the value of attribute des.
-
#end_speed ⇒ Object
Returns the value of attribute end_speed.
-
#gid ⇒ Object
Returns the value of attribute gid.
-
#on_1b ⇒ Object
Returns the value of attribute on_1b.
-
#on_2b ⇒ Object
Returns the value of attribute on_2b.
-
#on_3b ⇒ Object
Returns the value of attribute on_3b.
-
#pfx_x ⇒ Object
Returns the value of attribute pfx_x.
-
#pfx_z ⇒ Object
Returns the value of attribute pfx_z.
-
#pitch_id ⇒ Object
Returns the value of attribute pitch_id.
-
#pitch_type ⇒ Object
Returns the value of attribute pitch_type.
-
#pitcher_id ⇒ Object
Returns the value of attribute pitcher_id.
-
#px ⇒ Object
Returns the value of attribute px.
-
#pz ⇒ Object
Returns the value of attribute pz.
-
#spin_dir ⇒ Object
Returns the value of attribute spin_dir.
-
#spin_rate ⇒ Object
Returns the value of attribute spin_rate.
-
#start_speed ⇒ Object
Returns the value of attribute start_speed.
-
#sv_id ⇒ Object
Returns the value of attribute sv_id.
-
#sz_bot ⇒ Object
Returns the value of attribute sz_bot.
-
#sz_top ⇒ Object
Returns the value of attribute sz_top.
-
#type ⇒ Object
Returns the value of attribute type.
-
#type_confidence ⇒ Object
Returns the value of attribute type_confidence.
-
#vx0 ⇒ Object
Returns the value of attribute vx0.
-
#vy0 ⇒ Object
Returns the value of attribute vy0.
-
#vz0 ⇒ Object
Returns the value of attribute vz0.
-
#x ⇒ Object
Returns the value of attribute x.
-
#x0 ⇒ Object
Returns the value of attribute x0.
-
#y ⇒ Object
Returns the value of attribute y.
-
#y0 ⇒ Object
Returns the value of attribute y0.
-
#z0 ⇒ Object
Returns the value of attribute z0.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#ab_num ⇒ Object
Returns the value of attribute ab_num.
19 20 21 |
# File 'lib/pitch.rb', line 19 def ab_num @ab_num end |
#ax ⇒ Object
Returns the value of attribute ax.
22 23 24 |
# File 'lib/pitch.rb', line 22 def ax @ax end |
#ay ⇒ Object
Returns the value of attribute ay.
22 23 24 |
# File 'lib/pitch.rb', line 22 def ay @ay end |
#az ⇒ Object
Returns the value of attribute az.
22 23 24 |
# File 'lib/pitch.rb', line 22 def az @az end |
#batter_id ⇒ Object
Returns the value of attribute batter_id.
19 20 21 |
# File 'lib/pitch.rb', line 19 def batter_id @batter_id end |
#break_angle ⇒ Object
Returns the value of attribute break_angle.
22 23 24 |
# File 'lib/pitch.rb', line 22 def break_angle @break_angle end |
#break_length ⇒ Object
Returns the value of attribute break_length.
22 23 24 |
# File 'lib/pitch.rb', line 22 def break_length @break_length end |
#break_y ⇒ Object
Returns the value of attribute break_y.
22 23 24 |
# File 'lib/pitch.rb', line 22 def break_y @break_y end |
#des ⇒ Object
Returns the value of attribute des.
20 21 22 |
# File 'lib/pitch.rb', line 20 def des @des end |
#end_speed ⇒ Object
Returns the value of attribute end_speed.
20 21 22 |
# File 'lib/pitch.rb', line 20 def end_speed @end_speed end |
#gid ⇒ Object
Returns the value of attribute gid.
19 20 21 |
# File 'lib/pitch.rb', line 19 def gid @gid end |
#on_1b ⇒ Object
Returns the value of attribute on_1b.
23 24 25 |
# File 'lib/pitch.rb', line 23 def on_1b @on_1b end |
#on_2b ⇒ Object
Returns the value of attribute on_2b.
23 24 25 |
# File 'lib/pitch.rb', line 23 def on_2b @on_2b end |
#on_3b ⇒ Object
Returns the value of attribute on_3b.
23 24 25 |
# File 'lib/pitch.rb', line 23 def on_3b @on_3b end |
#pfx_x ⇒ Object
Returns the value of attribute pfx_x.
21 22 23 |
# File 'lib/pitch.rb', line 21 def pfx_x @pfx_x end |
#pfx_z ⇒ Object
Returns the value of attribute pfx_z.
21 22 23 |
# File 'lib/pitch.rb', line 21 def pfx_z @pfx_z end |
#pitch_id ⇒ Object
Returns the value of attribute pitch_id.
20 21 22 |
# File 'lib/pitch.rb', line 20 def pitch_id @pitch_id end |
#pitch_type ⇒ Object
Returns the value of attribute pitch_type.
22 23 24 |
# File 'lib/pitch.rb', line 22 def pitch_type @pitch_type end |
#pitcher_id ⇒ Object
Returns the value of attribute pitcher_id.
19 20 21 |
# File 'lib/pitch.rb', line 19 def pitcher_id @pitcher_id end |
#px ⇒ Object
Returns the value of attribute px.
21 22 23 |
# File 'lib/pitch.rb', line 21 def px @px end |
#pz ⇒ Object
Returns the value of attribute pz.
21 22 23 |
# File 'lib/pitch.rb', line 21 def pz @pz end |
#spin_dir ⇒ Object
Returns the value of attribute spin_dir.
23 24 25 |
# File 'lib/pitch.rb', line 23 def spin_dir @spin_dir end |
#spin_rate ⇒ Object
Returns the value of attribute spin_rate.
23 24 25 |
# File 'lib/pitch.rb', line 23 def spin_rate @spin_rate end |
#start_speed ⇒ Object
Returns the value of attribute start_speed.
20 21 22 |
# File 'lib/pitch.rb', line 20 def start_speed @start_speed end |
#sv_id ⇒ Object
Returns the value of attribute sv_id.
20 21 22 |
# File 'lib/pitch.rb', line 20 def sv_id @sv_id end |
#sz_bot ⇒ Object
Returns the value of attribute sz_bot.
21 22 23 |
# File 'lib/pitch.rb', line 21 def sz_bot @sz_bot end |
#sz_top ⇒ Object
Returns the value of attribute sz_top.
21 22 23 |
# File 'lib/pitch.rb', line 21 def sz_top @sz_top end |
#type ⇒ Object
Returns the value of attribute type.
20 21 22 |
# File 'lib/pitch.rb', line 20 def type @type end |
#type_confidence ⇒ Object
Returns the value of attribute type_confidence.
22 23 24 |
# File 'lib/pitch.rb', line 22 def type_confidence @type_confidence end |
#vx0 ⇒ Object
Returns the value of attribute vx0.
21 22 23 |
# File 'lib/pitch.rb', line 21 def vx0 @vx0 end |
#vy0 ⇒ Object
Returns the value of attribute vy0.
21 22 23 |
# File 'lib/pitch.rb', line 21 def vy0 @vy0 end |
#vz0 ⇒ Object
Returns the value of attribute vz0.
21 22 23 |
# File 'lib/pitch.rb', line 21 def vz0 @vz0 end |
#x ⇒ Object
Returns the value of attribute x.
20 21 22 |
# File 'lib/pitch.rb', line 20 def x @x end |
#x0 ⇒ Object
Returns the value of attribute x0.
21 22 23 |
# File 'lib/pitch.rb', line 21 def x0 @x0 end |
#y ⇒ Object
Returns the value of attribute y.
20 21 22 |
# File 'lib/pitch.rb', line 20 def y @y end |
#y0 ⇒ Object
Returns the value of attribute y0.
21 22 23 |
# File 'lib/pitch.rb', line 21 def y0 @y0 end |
#z0 ⇒ Object
Returns the value of attribute z0.
21 22 23 |
# File 'lib/pitch.rb', line 21 def z0 @z0 end |
Class Method Details
.get_pitch_name(code) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/pitch.rb', line 62 def self.get_pitch_name(code) case code when 'FS' 'Splitter' when 'SL' 'Slider' when 'FF' 'Fastball' # 4 seam when 'FT' 'Fastball' # 2 seam when 'SI' 'Sinker' when 'CH' 'Change' when 'FA' 'Fastball' when 'CU' 'Curve' when 'FC' 'Cutter' when 'KN' 'Knuckle' when 'KC' 'Knuckle Curve' else code end end |
Instance Method Details
#init(element) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/pitch.rb', line 25 def init(element) @des = element.attributes["des"] @pitch_id = element.attributes["id"] @type = element.attributes["type"] @x = element.attributes["x"] @y = element.attributes["y"] @sv_id = element.attributes["sv_id"] @start_speed = element.attributes["start_speed"] @end_speed = element.attributes["end_speed"] @sz_top = element.attributes["sz_top"] @sz_bot = element.attributes["sz_bot"] @pfx_x = element.attributes["pfx_x"] @pfx_z = element.attributes["pfx_z"] @px = element.attributes["px"] @pz = element.attributes["pz"] @x0 = element.attributes["x0"] @y0 = element.attributes["y0"] @z0 = element.attributes["z0"] @vx0 = element.attributes["vx0"] @vy0 = element.attributes["vy0"] @vz0 = element.attributes["vz0"] @ax = element.attributes["ax"] @ay = element.attributes["ay"] @az = element.attributes["az"] @break_y = element.attributes["break_y"] @break_angle = element.attributes["break_angle"] @break_length = element.attributes["break_length"] @pitch_type = element.attributes["pitch_type"] @type_confidence = element.attributes["type_confidence"] @spin_dir = element.attributes["spin_dir"] @spin_rate = element.attributes["spin_rate"] @on_1b = element.attributes["on_1b"] @on_2b = element.attributes["on_2b"] @on_3b = element.attributes["on_3b"] end |