Class: BattingAppearance

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

Overview

This class represents a batting record for a single player for a single game Note that this does NOT represent a single atbat of a player, but rather an appearance is a player’s stats over an entire game.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#aObject

Returns the value of attribute a.



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

def a
  @a
end

#abObject

Returns the value of attribute ab.



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

def ab
  @ab
end

#atbatsObject

Returns the value of attribute atbats.



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

def atbats
  @atbats
end

#avgObject

Returns the value of attribute avg.



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

def avg
  @avg
end

#batter_nameObject

Returns the value of attribute batter_name.



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

def batter_name
  @batter_name
end

#bbObject

Returns the value of attribute bb.



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

def bb
  @bb
end

#boObject

Returns the value of attribute bo.



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

def bo
  @bo
end

#dObject

Returns the value of attribute d.



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

def d
  @d
end

#eObject

Returns the value of attribute e.



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

def e
  @e
end

#fldgObject

Returns the value of attribute fldg.



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

def fldg
  @fldg
end

#hObject

Returns the value of attribute h.



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

def h
  @h
end

#hbpObject

Returns the value of attribute hbp.



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

def hbp
  @hbp
end

#hrObject

Returns the value of attribute hr.



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

def hr
  @hr
end

#lobObject

Returns the value of attribute lob.



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

def lob
  @lob
end

#pidObject

Returns the value of attribute pid.



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

def pid
  @pid
end

#playerObject

Returns the value of attribute player.



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

def player
  @player
end

#poObject

Returns the value of attribute po.



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

def po
  @po
end

#posObject

Returns the value of attribute pos.



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

def pos
  @pos
end

#rObject

Returns the value of attribute r.



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

def r
  @r
end

#rbiObject

Returns the value of attribute rbi.



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

def rbi
  @rbi
end

#sbObject

Returns the value of attribute sb.



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

def sb
  @sb
end

#sfObject

Returns the value of attribute sf.



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

def sf
  @sf
end

#soObject

Returns the value of attribute so.



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

def so
  @so
end

#tObject

Returns the value of attribute t.



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

def t
  @t
end

Instance Method Details

#get_atbatsObject

get the atbats associated with this appearance



51
52
53
# File 'lib/batting_appearance.rb', line 51

def get_atbats
  
end

#get_playerObject

Looks up the player record using the players.xml file for the player in this appearance



39
40
41
42
43
44
45
46
47
# File 'lib/batting_appearance.rb', line 39

def get_player
  if !self.player
    # retrieve player object
    player = Player.new
    player.init()
    self.player = player
  end
  self.player
end

#init(element) ⇒ Object

Used to initialize from box score data



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/batting_appearance.rb', line 12

def init(element)
  self.pid = element.attributes['id']
  self.batter_name = element.attributes['name']
  self.pos = element.attributes['pos']
  self.bo = element.attributes['bo']
  self.ab = element.attributes['ab']
  self.po = element.attributes['po']
  self.r = element.attributes['r']
  self.bb = element.attributes['bb']
  self.a = element.attributes['a']
  self.t = element.attributes['t']
  self.sf = element.attributes['sf']
  self.h = element.attributes['h']
  self.e = element.attributes['e']
  self.d = element.attributes['d']
  self.hbp = element.attributes['hbp']
  self.so = element.attributes['so']
  self.hr = element.attributes['hr']
  self.rbi = element.attributes['rbi']
  self.lob = element.attributes['lob']
  self.sb = element.attributes['sb']
  self.avg = element.attributes['avg']  # season avg
  self.fldg = element.attributes['fldg']
end