Class: YFantasy::Team
- Inherits:
-
BaseResource
- Object
- BaseResource
- YFantasy::Team
- Defined in:
- lib/y_fantasy/resources/team.rb,
lib/y_fantasy/resources/team/roster.rb,
lib/y_fantasy/resources/team/manager.rb,
lib/y_fantasy/resources/team/standings.rb,
lib/y_fantasy/resources/team/stat_collection.rb
Overview
Represents a fantasy team in a Yahoo Fantasy Sports league
Defined Under Namespace
Classes: Manager, Roster, Standings, StatCollection
Instance Attribute Summary collapse
-
#clinched_playoffs ⇒ Boolean?
readonly
Whether this team has clinched a playoff spot.
-
#division_id ⇒ Integer?
readonly
The ID of the division this team belongs to.
-
#draft_grade ⇒ String?
readonly
The grade assigned to this team’s draft.
-
#draft_recap_url ⇒ String?
readonly
The URL to this team’s draft recap.
-
#draft_results ⇒ Array<DraftResult>?
readonly
The draft results for this team.
-
#faab_balance ⇒ Integer?
readonly
The remaining Free Agent Acquisition Budget (FAAB) for this team.
-
#has_draft_grade ⇒ Boolean
readonly
Whether this team has a draft grade.
-
#league ⇒ League
readonly
Returns the league this team belongs to.
-
#league_key ⇒ String
readonly
Returns the league key for this team.
-
#league_scoring_type ⇒ String
readonly
The scoring type of the league (e.g. “head”, “point”).
-
#managers ⇒ Array<Manager>
readonly
Array of team managers.
-
#matchups ⇒ Array<Matchup>
readonly
The matchups for this team.
-
#name ⇒ String
readonly
The name of the team.
-
#number_of_moves ⇒ Integer
readonly
The number of roster moves made by this team.
-
#number_of_trades ⇒ Integer
readonly
The number of trades made by this team.
-
#roster ⇒ Roster?
readonly
The roster for this team.
-
#roster_adds ⇒ String
readonly
The roster adds information for this team.
-
#stats ⇒ StatCollection?
readonly
The stat collection for this team.
-
#team_id ⇒ Integer
readonly
The ID for this team.
-
#team_key ⇒ String
readonly
The unique key for this team.
-
#team_logos ⇒ Hash
readonly
The team logo information.
-
#team_standings ⇒ Standings?
readonly
The standings for this team.
-
#url ⇒ String
readonly
The URL to the team’s Yahoo Fantasy page.
-
#waiver_priority ⇒ Integer?
readonly
This team’s waiver priority.
Instance Method Summary collapse
-
#manager ⇒ Manager
Returns the primary manager of the team.
-
#matchups_for_week(week) ⇒ Array<Matchup>
Gets the matchups for this team for a specific week.
-
#roster_for_week(week, player_stats: false) ⇒ Roster
Gets the roster for this team for a specific week.
-
#simple_standings ⇒ Hash
Returns a hash of simplified standings information for the team.
-
#stats_for_week(week) ⇒ StatCollection
Gets the stats for this team for a specific week.
Methods inherited from BaseResource
collection_name, dependent?, find, find_all, #key, resource_name
Methods included from Subresourceable
Instance Attribute Details
#clinched_playoffs ⇒ Boolean? (readonly)
Returns whether this team has clinched a playoff spot.
56 |
# File 'lib/y_fantasy/resources/team.rb', line 56 option :clinched_playoffs, optional: true, type: Types::Params::Bool |
#division_id ⇒ Integer? (readonly)
Returns the ID of the division this team belongs to.
60 |
# File 'lib/y_fantasy/resources/team.rb', line 60 option :division_id, optional: true, type: Types::Coercible::Integer |
#draft_grade ⇒ String? (readonly)
Returns the grade assigned to this team’s draft.
64 |
# File 'lib/y_fantasy/resources/team.rb', line 64 option :draft_grade, optional: true |
#draft_recap_url ⇒ String? (readonly)
Returns the URL to this team’s draft recap.
68 |
# File 'lib/y_fantasy/resources/team.rb', line 68 option :draft_recap_url, optional: true |
#draft_results ⇒ Array<DraftResult>? (readonly)
Returns the draft results for this team.
90 |
# File 'lib/y_fantasy/resources/team.rb', line 90 option :draft_results, optional: true, type: array_of(DraftResult) |
#faab_balance ⇒ Integer? (readonly)
Returns the remaining Free Agent Acquisition Budget (FAAB) for this team.
72 |
# File 'lib/y_fantasy/resources/team.rb', line 72 option :faab_balance, optional: true, type: Types::Coercible::Integer |
#has_draft_grade ⇒ Boolean (readonly)
Returns whether this team has a draft grade.
18 |
# File 'lib/y_fantasy/resources/team.rb', line 18 option :has_draft_grade, type: Types::Params::Bool |
#league ⇒ League (readonly)
Returns the league this team belongs to
84 |
# File 'lib/y_fantasy/resources/team.rb', line 84 option :league, optional: true |
#league_key ⇒ String (readonly)
Returns the league key for this team
80 |
# File 'lib/y_fantasy/resources/team.rb', line 80 option :league_key, optional: true |
#league_scoring_type ⇒ String (readonly)
Returns the scoring type of the league (e.g. “head”, “point”).
22 |
# File 'lib/y_fantasy/resources/team.rb', line 22 option :league_scoring_type |
#managers ⇒ Array<Manager> (readonly)
Returns Array of team managers.
26 |
# File 'lib/y_fantasy/resources/team.rb', line 26 option :managers, type: array_of(Manager) |
#matchups ⇒ Array<Matchup> (readonly)
Returns the matchups for this team.
94 |
# File 'lib/y_fantasy/resources/team.rb', line 94 option :matchups, optional: true, type: array_of(Matchup), default: -> { [] } |
#name ⇒ String (readonly)
Returns the name of the team.
30 |
# File 'lib/y_fantasy/resources/team.rb', line 30 option :name |
#number_of_moves ⇒ Integer (readonly)
Returns the number of roster moves made by this team.
34 |
# File 'lib/y_fantasy/resources/team.rb', line 34 option :number_of_moves, type: Types::Coercible::Integer |
#number_of_trades ⇒ Integer (readonly)
Returns the number of trades made by this team.
38 |
# File 'lib/y_fantasy/resources/team.rb', line 38 option :number_of_trades, type: Types::Coercible::Integer |
#roster ⇒ Roster? (readonly)
Returns the roster for this team.
98 |
# File 'lib/y_fantasy/resources/team.rb', line 98 option :roster, optional: true, type: instance_of(Roster) |
#roster_adds ⇒ String (readonly)
Returns the roster adds information for this team.
42 |
# File 'lib/y_fantasy/resources/team.rb', line 42 option :roster_adds |
#stats ⇒ StatCollection? (readonly)
Returns the stat collection for this team.
102 |
# File 'lib/y_fantasy/resources/team.rb', line 102 option :stats, optional: true, type: instance_of(StatCollection), default: -> {} |
#team_id ⇒ Integer (readonly)
Returns the ID for this team.
14 |
# File 'lib/y_fantasy/resources/team.rb', line 14 option :team_id, type: Types::Coercible::Integer |
#team_key ⇒ String (readonly)
Returns the unique key for this team.
10 |
# File 'lib/y_fantasy/resources/team.rb', line 10 option :team_key |
#team_logos ⇒ Hash (readonly)
Returns the team logo information.
46 |
# File 'lib/y_fantasy/resources/team.rb', line 46 option :team_logos, type: ->(h) { h[:team_logo] } |
#team_standings ⇒ Standings? (readonly)
Returns the standings for this team.
106 |
# File 'lib/y_fantasy/resources/team.rb', line 106 option :team_standings, optional: true, type: instance_of(Standings) |
#url ⇒ String (readonly)
Returns the URL to the team’s Yahoo Fantasy page.
50 |
# File 'lib/y_fantasy/resources/team.rb', line 50 option :url |
#waiver_priority ⇒ Integer? (readonly)
Returns This team’s waiver priority.
76 |
# File 'lib/y_fantasy/resources/team.rb', line 76 option :waiver_priority, optional: true, type: Types::Coercible::Integer |
Instance Method Details
#manager ⇒ Manager
Returns the primary manager of the team
120 121 122 |
# File 'lib/y_fantasy/resources/team.rb', line 120 def manager managers.find { |manager| !manager.is_comanager } end |
#matchups_for_week(week) ⇒ Array<Matchup>
Gets the matchups for this team for a specific week
155 156 157 |
# File 'lib/y_fantasy/resources/team.rb', line 155 def matchups_for_week(week) @matchups = self.class.find(team_key, with: :matchups, week: week).matchups end |
#roster_for_week(week, player_stats: false) ⇒ Roster
Gets the roster for this team for a specific week
163 164 165 166 |
# File 'lib/y_fantasy/resources/team.rb', line 163 def roster_for_week(week, player_stats: false) with = player_stats ? {roster: {players: :stats}} : :roster @roster = self.class.find(team_key, with: with, week: week).roster end |
#simple_standings ⇒ Hash
Returns a hash of simplified standings information for the team
126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/y_fantasy/resources/team.rb', line 126 def simple_standings { team_key: team_key, name: name, rank: rank, playoff_seed: playoff_seed, wins: wins, losses: losses, ties: ties, points_for: points_for, points_against: points_against } end |
#stats_for_week(week) ⇒ StatCollection
Gets the stats for this team for a specific week
171 172 173 |
# File 'lib/y_fantasy/resources/team.rb', line 171 def stats_for_week(week) @stats = self.class.find(team_key, with: :stats, week: week).stats end |