Class: Pitcher

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/mlb_gd2/pitcher.rb

Constant Summary

Constants included from Helpers

Helpers::GD2_MLB_BASE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#boxscore, #build_base_url, #generate_nokogiri_html, #generate_nokogiri_xml, #valid_game?

Constructor Details

#initialize(pitcher_xml) ⇒ Pitcher

Returns a new instance of Pitcher.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/mlb_gd2/pitcher.rb', line 11

def initialize(pitcher_xml)
  @name        = pitcher_xml.attribute("name").value
  @full_name  = pitcher_xml.attribute("name_display_first_last").value
  @outs        = pitcher_xml.attribute("out").value
  @walks       = pitcher_xml.attribute("bb").value
  @strikeouts  = pitcher_xml.attribute("so").value
  @hits        = pitcher_xml.attribute("h").value
  @runs        = pitcher_xml.attribute("r").value
  @homeruns    = pitcher_xml.attribute("hr").value
  @earned_runs = pitcher_xml.attribute("er").value
  @era         = pitcher_xml.attribute("era").value
end

Instance Attribute Details

#earned_runsObject (readonly)

Returns the value of attribute earned_runs.



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

def earned_runs
  @earned_runs
end

#eraObject (readonly)

Returns the value of attribute era.



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

def era
  @era
end

#full_nameObject (readonly)

Returns the value of attribute full_name.



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

def full_name
  @full_name
end

#hitsObject (readonly)

Returns the value of attribute hits.



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

def hits
  @hits
end

#homerunsObject (readonly)

Returns the value of attribute homeruns.



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

def homeruns
  @homeruns
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#outsObject (readonly)

Returns the value of attribute outs.



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

def outs
  @outs
end

#runsObject (readonly)

Returns the value of attribute runs.



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

def runs
  @runs
end

#strikeoutsObject (readonly)

Returns the value of attribute strikeouts.



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

def strikeouts
  @strikeouts
end

#walksObject (readonly)

Returns the value of attribute walks.



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

def walks
  @walks
end

Instance Method Details

#ipObject



24
25
26
# File 'lib/mlb_gd2/pitcher.rb', line 24

def ip
  "#{(outs.to_i / 3).to_s}.#{outs.to_i%3}"
end