Sha256: 456494bf8fe69c63bab51fa72b76d6574cf5a352c8c308381253ac154890e00c
Contents?: true
Size: 818 Bytes
Versions: 9
Compression:
Stored size: 818 Bytes
Contents
module SportsDataApi module Mlb class GameStat attr_reader :player_id def initialize(xml) if xml.is_a? Nokogiri::XML::Element stat_ivar = self.instance_variable_set("@#{xml.name}", {}) self.class.class_eval { attr_reader :"#{xml.name}" } xml.attributes.each do | attr_name, attr_value| stat_ivar[attr_name.to_sym] = attr_value.value end xml.xpath('.//*').each do |other_stat| if other_stat.is_a? Nokogiri::XML::Element stat_ivar[other_stat.name.to_sym] = {} other_stat.attributes.each do | attr_name, attr_value| stat_ivar[other_stat.name.to_sym][attr_name.to_sym] = attr_value.value end end end end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems