Sha256: b7e024aa53b53c054c171c963b1d82806134511f75a62aa2527862ccaf0f6d39
Contents?: true
Size: 695 Bytes
Versions: 16
Compression:
Stored size: 695 Bytes
Contents
module SportsDataApi module Nhl 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 # NHL 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
16 entries across 16 versions & 1 rubygems