Class: SportsDataApi::Mlb::Team

Inherits:
Object
  • Object
show all
Defined in:
lib/sports_data_api/mlb/team.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ Team

Returns a new instance of Team.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/sports_data_api/mlb/team.rb', line 6

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

Instance Attribute Details

#aliasObject (readonly)

Returns the value of attribute alias.



4
5
6
# File 'lib/sports_data_api/mlb/team.rb', line 4

def alias
  @alias
end

#divisionObject (readonly)

Returns the value of attribute division.



4
5
6
# File 'lib/sports_data_api/mlb/team.rb', line 4

def division
  @division
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/sports_data_api/mlb/team.rb', line 4

def id
  @id
end

#leagueObject (readonly)

Returns the value of attribute league.



4
5
6
# File 'lib/sports_data_api/mlb/team.rb', line 4

def league
  @league
end

#marketObject (readonly)

Returns the value of attribute market.



4
5
6
# File 'lib/sports_data_api/mlb/team.rb', line 4

def market
  @market
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/sports_data_api/mlb/team.rb', line 4

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object

Compare the Team with another team



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sports_data_api/mlb/team.rb', line 20

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