Class: SportsDataApi::Nfl::Team
- Inherits:
-
Object
- Object
- SportsDataApi::Nfl::Team
- Defined in:
- lib/sports_data_api/nfl/team.rb
Instance Attribute Summary collapse
-
#conference ⇒ Object
readonly
Returns the value of attribute conference.
-
#division ⇒ Object
readonly
Returns the value of attribute division.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#market ⇒ Object
readonly
Returns the value of attribute market.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#players ⇒ Object
readonly
Returns the value of attribute players.
-
#points ⇒ Object
readonly
Returns the value of attribute points.
-
#quarters ⇒ Object
readonly
Returns the value of attribute quarters.
-
#remaining_challenges ⇒ Object
readonly
Returns the value of attribute remaining_challenges.
-
#remaining_timeouts ⇒ Object
readonly
Returns the value of attribute remaining_timeouts.
-
#score ⇒ Object
readonly
Sum the score of each quarter.
-
#statistics ⇒ Object
readonly
Returns the value of attribute statistics.
-
#venue ⇒ Object
readonly
Returns the value of attribute venue.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Compare the Team with another team.
-
#initialize(team_hash, conference = nil, division = nil) ⇒ Team
constructor
A new instance of Team.
Constructor Details
#initialize(team_hash, conference = nil, division = nil) ⇒ Team
Returns a new instance of Team.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/sports_data_api/nfl/team.rb', line 7 def initialize(team_hash, conference = nil, division = nil) if team_hash @id = team_hash['id'] @name = team_hash['name'] @conference = conference @division = division @market = team_hash['market'] @remaining_challenges = team_hash['remaining_challenges'] @remaining_timeouts = team_hash['remaining_timeouts'] @quarters = [] if team_hash['scoring'] team_hash['scoring'].each do |scoring_hash| @quarters[scoring_hash['quarter']-1] = scoring_hash['points'] end end @quarters = @quarters.fill(0, @quarters.size, 4 - @quarters.size) # Parse the Venue data if it exists if team_hash.key?('venue') @venue = Venue.new(team_hash['venue']) end if team_hash['statistics'] @statistics = parse_team_statistics(team_hash['statistics']) @players = parse_player_statistics(team_hash['statistics']) end if team_hash['players'] @players = TeamRoster.new(team_hash).players end @points = team_hash['points'] || score end end |
Instance Attribute Details
#conference ⇒ Object (readonly)
Returns the value of attribute conference.
4 5 6 |
# File 'lib/sports_data_api/nfl/team.rb', line 4 def conference @conference end |
#division ⇒ Object (readonly)
Returns the value of attribute division.
4 5 6 |
# File 'lib/sports_data_api/nfl/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/nfl/team.rb', line 4 def id @id end |
#market ⇒ Object (readonly)
Returns the value of attribute market.
4 5 6 |
# File 'lib/sports_data_api/nfl/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/nfl/team.rb', line 4 def name @name end |
#players ⇒ Object (readonly)
Returns the value of attribute players.
4 5 6 |
# File 'lib/sports_data_api/nfl/team.rb', line 4 def players @players end |
#points ⇒ Object (readonly)
Returns the value of attribute points.
4 5 6 |
# File 'lib/sports_data_api/nfl/team.rb', line 4 def points @points end |
#quarters ⇒ Object (readonly)
Returns the value of attribute quarters.
4 5 6 |
# File 'lib/sports_data_api/nfl/team.rb', line 4 def quarters @quarters end |
#remaining_challenges ⇒ Object (readonly)
Returns the value of attribute remaining_challenges.
4 5 6 |
# File 'lib/sports_data_api/nfl/team.rb', line 4 def remaining_challenges @remaining_challenges end |
#remaining_timeouts ⇒ Object (readonly)
Returns the value of attribute remaining_timeouts.
4 5 6 |
# File 'lib/sports_data_api/nfl/team.rb', line 4 def remaining_timeouts @remaining_timeouts end |
#score ⇒ Object (readonly)
Sum the score of each quarter
42 43 44 |
# File 'lib/sports_data_api/nfl/team.rb', line 42 def score @score end |
#statistics ⇒ Object (readonly)
Returns the value of attribute statistics.
4 5 6 |
# File 'lib/sports_data_api/nfl/team.rb', line 4 def statistics @statistics end |
#venue ⇒ Object (readonly)
Returns the value of attribute venue.
4 5 6 |
# File 'lib/sports_data_api/nfl/team.rb', line 4 def venue @venue end |
Instance Method Details
#==(other) ⇒ Object
Compare the Team with another team
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/sports_data_api/nfl/team.rb', line 48 def ==(other) # Must have an id to compare return false if id.nil? if other.is_a? SportsDataApi::Nfl::Team other.id && id === other.id elsif other.is_a? Symbol id.to_sym === other else super(other) end end |