Sha256: 07457c2bf3cfea5907a950bb3aacd9932b0a1ee18faed6172bcbb67dbd98093f

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

module SportsDataApi
  module Ncaamb
    class Team
      attr_reader :id, :name, :market, :alias, :conference, :division,
                  :stats, :players, :points

      def initialize(xml, conference = nil, division = nil)
        xml = xml.first if xml.is_a? Nokogiri::XML::NodeSet
        if xml.is_a? Nokogiri::XML::Element
          @id = xml['id']
          @name = xml['name']
          @market = xml['market']
          @alias = xml['alias']
          @points = xml['points'] ? xml['points'].to_i : nil
          @conference = conference
          @division = division
          @players = xml.xpath("players/player").map do |player_xml|
            Player.new(player_xml)
          end
        end
      end

      ##
      # Compare the Team with another team
      def ==(other)
        # Must have an id to compare
        return false if self.id.nil?

        if other.is_a? SportsDataApi::Ncaamb::Team
          return false if other.id.nil?
          self.id === other.id
        elsif other.is_a? Symbol
          self.id.to_sym === other
        else
          super(other)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sports_data_api-0.2.4 lib/sports_data_api/ncaamb/team.rb
sports_data_api-0.2.3 lib/sports_data_api/ncaamb/team.rb
sports_data_api-0.2.2 lib/sports_data_api/ncaamb/team.rb
sports_data_api-0.2.1 lib/sports_data_api/ncaamb/team.rb