Sha256: 839a7a944ce5033ca913d147bece6d9e783f1d45125311ee55f69d5bc38f66b4
Contents?: true
Size: 695 Bytes
Versions: 15
Compression:
Stored size: 695 Bytes
Contents
module SportsDataApi module Nba class Season attr_reader :id, :year, :type, :games def initialize(xml) if xml.is_a? Nokogiri::XML::NodeSet @id = xml.first["id"] @year = xml.first["year"].to_i @type = xml.first["type"].to_sym @games = xml.first.xpath("games/game").map do |game_xml| Game.new(year: @year, season: @type, xml: game_xml) end end end ## # Check if the requested season is a valid # NBA season type. # # The only valid types are: :pre, :reg, :pst def self.valid?(season) [:PRE, :REG, :PST].include?(season) end end end end
Version data entries
15 entries across 15 versions & 1 rubygems