Sha256: 3ab1b802660216ecbdb6886a5ae2c1eb7b22f0ed489e65c0f618c2aae951dc44

Contents?: true

Size: 872 Bytes

Versions: 6

Compression:

Stored size: 872 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 self.id.nil?

        if other.is_a? SportsDataApi::Mlb::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

6 entries across 6 versions & 1 rubygems

Version Path
sports_data_api-0.2.4 lib/sports_data_api/mlb/team.rb
sports_data_api-0.2.3 lib/sports_data_api/mlb/team.rb
sports_data_api-0.2.2 lib/sports_data_api/mlb/team.rb
sports_data_api-0.2.1 lib/sports_data_api/mlb/team.rb
sports_data_api-0.2.0 lib/sports_data_api/mlb/team.rb
sports_data_api-0.1.0 lib/sports_data_api/mlb/team.rb