Class: SportsDataApi::Mlb::Team
- Inherits:
-
Object
- Object
- SportsDataApi::Mlb::Team
- Defined in:
- lib/sports_data_api/mlb/team.rb
Instance Attribute Summary collapse
-
#alias ⇒ Object
readonly
Returns the value of attribute alias.
-
#division ⇒ Object
readonly
Returns the value of attribute division.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#league ⇒ Object
readonly
Returns the value of attribute league.
-
#market ⇒ Object
readonly
Returns the value of attribute market.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Compare the Team with another team.
-
#initialize(xml) ⇒ Team
constructor
A new instance of Team.
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
#alias ⇒ Object (readonly)
Returns the value of attribute alias.
4 5 6 |
# File 'lib/sports_data_api/mlb/team.rb', line 4 def alias @alias end |
#division ⇒ Object (readonly)
Returns the value of attribute division.
4 5 6 |
# File 'lib/sports_data_api/mlb/team.rb', line 4 def division @division end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/sports_data_api/mlb/team.rb', line 4 def id @id end |
#league ⇒ Object (readonly)
Returns the value of attribute league.
4 5 6 |
# File 'lib/sports_data_api/mlb/team.rb', line 4 def league @league end |
#market ⇒ Object (readonly)
Returns the value of attribute market.
4 5 6 |
# File 'lib/sports_data_api/mlb/team.rb', line 4 def market @market end |
#name ⇒ Object (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 |