Sha256: 907ed3ca02e079e115c37c37143ae23352264488802248a185c7f585d7ddaf82

Contents?: true

Size: 829 Bytes

Versions: 3

Compression:

Stored size: 829 Bytes

Contents

module SportsDataApi
  module Mlb
    class Team
      attr_reader :id, :name, :market, :alias, :league, :division

      def initialize(xml)
        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['abbr']
          @league = xml['league']
          @division = xml['division']
        end
      end

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

        if other.is_a? SportsDataApi::Mlb::Team
          other.id && id === other.id
        elsif other.is_a? Symbol
          id.to_sym === other
        else
          super(other)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sports_data_api-0.10.1 lib/sports_data_api/mlb/team.rb
sports_data_api-0.10.0 lib/sports_data_api/mlb/team.rb
sports_data_api-0.9.2 lib/sports_data_api/mlb/team.rb