Class: BattingAppearance
- Inherits:
- 
      Object
      
        - Object
- BattingAppearance
 
- 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
- 
  
    
      #a  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute a. 
- 
  
    
      #ab  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute ab. 
- 
  
    
      #atbats  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute atbats. 
- 
  
    
      #avg  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute avg. 
- 
  
    
      #batter_name  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute batter_name. 
- 
  
    
      #bb  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute bb. 
- 
  
    
      #bo  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute bo. 
- 
  
    
      #d  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute d. 
- 
  
    
      #e  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute e. 
- 
  
    
      #fldg  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute fldg. 
- 
  
    
      #h  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute h. 
- 
  
    
      #hbp  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute hbp. 
- 
  
    
      #hr  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute hr. 
- 
  
    
      #lob  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute lob. 
- 
  
    
      #pid  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute pid. 
- 
  
    
      #player  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute player. 
- 
  
    
      #po  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute po. 
- 
  
    
      #pos  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute pos. 
- 
  
    
      #r  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute r. 
- 
  
    
      #rbi  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute rbi. 
- 
  
    
      #sb  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute sb. 
- 
  
    
      #sf  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute sf. 
- 
  
    
      #so  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute so. 
- 
  
    
      #t  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute t. 
Instance Method Summary collapse
- 
  
    
      #get_atbats  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    get the atbats associated with this appearance. 
- 
  
    
      #get_player  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Looks up the player record using the players.xml file for the player in this appearance. 
- 
  
    
      #init(element)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Used to initialize from box score data. 
Instance Attribute Details
#a ⇒ Object
Returns the value of attribute a.
| 8 9 10 | # File 'lib/batting_appearance.rb', line 8 def a @a end | 
#ab ⇒ Object
Returns the value of attribute ab.
| 8 9 10 | # File 'lib/batting_appearance.rb', line 8 def ab @ab end | 
#atbats ⇒ Object
Returns the value of attribute atbats.
| 9 10 11 | # File 'lib/batting_appearance.rb', line 9 def atbats @atbats end | 
#avg ⇒ Object
Returns the value of attribute avg.
| 8 9 10 | # File 'lib/batting_appearance.rb', line 8 def avg @avg end | 
#batter_name ⇒ Object
Returns the value of attribute batter_name.
| 8 9 10 | # File 'lib/batting_appearance.rb', line 8 def batter_name @batter_name end | 
#bb ⇒ Object
Returns the value of attribute bb.
| 8 9 10 | # File 'lib/batting_appearance.rb', line 8 def bb @bb end | 
#bo ⇒ Object
Returns the value of attribute bo.
| 8 9 10 | # File 'lib/batting_appearance.rb', line 8 def bo @bo end | 
#d ⇒ Object
Returns the value of attribute d.
| 8 9 10 | # File 'lib/batting_appearance.rb', line 8 def d @d end | 
#e ⇒ Object
Returns the value of attribute e.
| 8 9 10 | # File 'lib/batting_appearance.rb', line 8 def e @e end | 
#fldg ⇒ Object
Returns the value of attribute fldg.
| 8 9 10 | # File 'lib/batting_appearance.rb', line 8 def fldg @fldg end | 
#h ⇒ Object
Returns the value of attribute h.
| 8 9 10 | # File 'lib/batting_appearance.rb', line 8 def h @h end | 
#hbp ⇒ Object
Returns the value of attribute hbp.
| 8 9 10 | # File 'lib/batting_appearance.rb', line 8 def hbp @hbp end | 
#hr ⇒ Object
Returns the value of attribute hr.
| 8 9 10 | # File 'lib/batting_appearance.rb', line 8 def hr @hr end | 
#lob ⇒ Object
Returns the value of attribute lob.
| 8 9 10 | # File 'lib/batting_appearance.rb', line 8 def lob @lob end | 
#pid ⇒ Object
Returns the value of attribute pid.
| 8 9 10 | # File 'lib/batting_appearance.rb', line 8 def pid @pid end | 
#player ⇒ Object
Returns the value of attribute player.
| 9 10 11 | # File 'lib/batting_appearance.rb', line 9 def player @player end | 
#po ⇒ Object
Returns the value of attribute po.
| 8 9 10 | # File 'lib/batting_appearance.rb', line 8 def po @po end | 
#pos ⇒ Object
Returns the value of attribute pos.
| 8 9 10 | # File 'lib/batting_appearance.rb', line 8 def pos @pos end | 
#r ⇒ Object
Returns the value of attribute r.
| 8 9 10 | # File 'lib/batting_appearance.rb', line 8 def r @r end | 
#rbi ⇒ Object
Returns the value of attribute rbi.
| 8 9 10 | # File 'lib/batting_appearance.rb', line 8 def rbi @rbi end | 
#sb ⇒ Object
Returns the value of attribute sb.
| 8 9 10 | # File 'lib/batting_appearance.rb', line 8 def sb @sb end | 
#sf ⇒ Object
Returns the value of attribute sf.
| 8 9 10 | # File 'lib/batting_appearance.rb', line 8 def sf @sf end | 
#so ⇒ Object
Returns the value of attribute so.
| 8 9 10 | # File 'lib/batting_appearance.rb', line 8 def so @so end | 
#t ⇒ Object
Returns the value of attribute t.
| 8 9 10 | # File 'lib/batting_appearance.rb', line 8 def t @t end | 
Instance Method Details
#get_atbats ⇒ Object
get the atbats associated with this appearance
| 51 52 53 | # File 'lib/batting_appearance.rb', line 51 def get_atbats end | 
#get_player ⇒ Object
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 |