Class: Team
Constant Summary
Constants included from Helpers
Instance Attribute Summary collapse
-
#batters ⇒ Object
readonly
Returns the value of attribute batters.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#hits ⇒ Object
readonly
Returns the value of attribute hits.
-
#linescore ⇒ Object
readonly
Returns the value of attribute linescore.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#pitchers ⇒ Object
readonly
Returns the value of attribute pitchers.
-
#runs ⇒ Object
readonly
Returns the value of attribute runs.
Instance Method Summary collapse
-
#initialize(boxscore, flag) ⇒ Team
constructor
A new instance of Team.
Methods included from Helpers
#boxscore, #build_base_url, #generate_nokogiri_html, #generate_nokogiri_xml, #valid_game?
Constructor Details
#initialize(boxscore, flag) ⇒ Team
Returns a new instance of Team.
13 14 15 16 17 18 19 20 21 |
# File 'lib/mlb_gd2/team.rb', line 13 def initialize(boxscore, flag) @name = boxscore.attribute("#{flag}_fname").value @linescore = boxscore.xpath("//inning_line_score").map { |inning| inning["#{flag}"] } @runs = boxscore.xpath("//linescore").first.attribute("#{flag}_team_runs").value @hits = boxscore.xpath("//linescore").first.attribute("#{flag}_team_hits").value @errors = boxscore.xpath("//linescore").first.attribute("#{flag}_team_errors").value @batters = boxscore.search("batting[team_flag='#{flag}']>batter").map { |batter_xml| Batter.new(batter_xml) } @pitchers = boxscore.search("pitching[team_flag='#{flag}']>pitcher").map { |pitcher_xml| Pitcher.new(pitcher_xml) } end |
Instance Attribute Details
#batters ⇒ Object (readonly)
Returns the value of attribute batters.
9 10 11 |
# File 'lib/mlb_gd2/team.rb', line 9 def batters @batters end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
9 10 11 |
# File 'lib/mlb_gd2/team.rb', line 9 def errors @errors end |
#hits ⇒ Object (readonly)
Returns the value of attribute hits.
9 10 11 |
# File 'lib/mlb_gd2/team.rb', line 9 def hits @hits end |
#linescore ⇒ Object (readonly)
Returns the value of attribute linescore.
9 10 11 |
# File 'lib/mlb_gd2/team.rb', line 9 def linescore @linescore end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/mlb_gd2/team.rb', line 9 def name @name end |
#pitchers ⇒ Object (readonly)
Returns the value of attribute pitchers.
9 10 11 |
# File 'lib/mlb_gd2/team.rb', line 9 def pitchers @pitchers end |
#runs ⇒ Object (readonly)
Returns the value of attribute runs.
9 10 11 |
# File 'lib/mlb_gd2/team.rb', line 9 def runs @runs end |