Class: SportsDataApi::Mlb::Player

Inherits:
Object
  • Object
show all
Defined in:
lib/sports_data_api/mlb/player.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml, team_id) ⇒ Player

Returns a new instance of Player.



5
6
7
8
9
10
11
12
13
14
# File 'lib/sports_data_api/mlb/player.rb', line 5

def initialize(xml, team_id)
  if xml.is_a? Nokogiri::XML::Element
    player_ivar = self.instance_variable_set("@#{xml.name}", {})
    self.class.class_eval { attr_reader :"#{xml.name}" }
    player_ivar[:team_id] = team_id
    xml.attributes.each do | attr_name, attr_value|
      player_ivar[attr_name.to_sym] = attr_value.value
    end
  end
end

Instance Attribute Details

#team_idObject (readonly)

Returns the value of attribute team_id.



4
5
6
# File 'lib/sports_data_api/mlb/player.rb', line 4

def team_id
  @team_id
end