Class: SportsDataApi::Nba::Player

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ Player



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/sports_data_api/nba/player.rb', line 6

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

    stats_xml = xml.xpath('statistics')
    if stats_xml.is_a? Nokogiri::XML::NodeSet and stats_xml.count > 0
      @stats = SportsDataApi::Stats.new(stats_xml.first)
    end
  end
end

Instance Attribute Details

#statsObject (readonly)

Returns the value of attribute stats.



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

def stats
  @stats
end