Class: YFantasy::Team

Inherits:
BaseResource show all
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

Instance Method Summary collapse

Methods inherited from BaseResource

collection_name, dependent?, find, find_all, #key, resource_name

Methods included from Subresourceable

included

Instance Attribute Details

#clinched_playoffsBoolean? (readonly)

Returns whether this team has clinched a playoff spot.

Returns:

  • (Boolean, nil)

    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_idInteger? (readonly)

Returns the ID of the division this team belongs to.

Returns:

  • (Integer, nil)

    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_gradeString? (readonly)

Returns the grade assigned to this team’s draft.

Returns:

  • (String, nil)

    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_urlString? (readonly)

Returns the URL to this team’s draft recap.

Returns:

  • (String, nil)

    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_resultsArray<DraftResult>? (readonly)

Returns the draft results for this team.

Returns:

  • (Array<DraftResult>, nil)

    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_balanceInteger? (readonly)

Returns the remaining Free Agent Acquisition Budget (FAAB) for this team.

Returns:

  • (Integer, nil)

    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_gradeBoolean (readonly)

Returns whether this team has a draft grade.

Returns:

  • (Boolean)

    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

#leagueLeague (readonly)

Returns the league this team belongs to

Returns:

  • (League)

    the league object



84
# File 'lib/y_fantasy/resources/team.rb', line 84

option :league, optional: true

#league_keyString (readonly)

Returns the league key for this team

Returns:

  • (String)

    the league key



80
# File 'lib/y_fantasy/resources/team.rb', line 80

option :league_key, optional: true

#league_scoring_typeString (readonly)

Returns the scoring type of the league (e.g. “head”, “point”).

Returns:

  • (String)

    the scoring type of the league (e.g. “head”, “point”)



22
# File 'lib/y_fantasy/resources/team.rb', line 22

option :league_scoring_type

#managersArray<Manager> (readonly)

Returns Array of team managers.

Returns:

  • (Array<Manager>)

    Array of team managers



26
# File 'lib/y_fantasy/resources/team.rb', line 26

option :managers, type: array_of(Manager)

#matchupsArray<Matchup> (readonly)

Returns the matchups for this team.

Returns:

  • (Array<Matchup>)

    the matchups for this team



94
# File 'lib/y_fantasy/resources/team.rb', line 94

option :matchups, optional: true, type: array_of(Matchup), default: -> { [] }

#nameString (readonly)

Returns the name of the team.

Returns:

  • (String)

    the name of the team



30
# File 'lib/y_fantasy/resources/team.rb', line 30

option :name

#number_of_movesInteger (readonly)

Returns the number of roster moves made by this team.

Returns:

  • (Integer)

    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_tradesInteger (readonly)

Returns the number of trades made by this team.

Returns:

  • (Integer)

    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

#rosterRoster? (readonly)

Returns the roster for this team.

Returns:

  • (Roster, nil)

    the roster for this team



98
# File 'lib/y_fantasy/resources/team.rb', line 98

option :roster, optional: true, type: instance_of(Roster)

#roster_addsString (readonly)

Returns the roster adds information for this team.

Returns:

  • (String)

    the roster adds information for this team



42
# File 'lib/y_fantasy/resources/team.rb', line 42

option :roster_adds

#statsStatCollection? (readonly)

Returns the stat collection for this team.

Returns:



102
# File 'lib/y_fantasy/resources/team.rb', line 102

option :stats, optional: true, type: instance_of(StatCollection), default: -> {}

#team_idInteger (readonly)

Returns the ID for this team.

Returns:

  • (Integer)

    the ID for this team



14
# File 'lib/y_fantasy/resources/team.rb', line 14

option :team_id, type: Types::Coercible::Integer

#team_keyString (readonly)

Returns the unique key for this team.

Returns:

  • (String)

    the unique key for this team



10
# File 'lib/y_fantasy/resources/team.rb', line 10

option :team_key

#team_logosHash (readonly)

Returns the team logo information.

Returns:

  • (Hash)

    the team logo information



46
# File 'lib/y_fantasy/resources/team.rb', line 46

option :team_logos, type: ->(h) { h[:team_logo] }

#team_standingsStandings? (readonly)

Returns the standings for this team.

Returns:

  • (Standings, nil)

    the standings for this team



106
# File 'lib/y_fantasy/resources/team.rb', line 106

option :team_standings, optional: true, type: instance_of(Standings)

#urlString (readonly)

Returns the URL to the team’s Yahoo Fantasy page.

Returns:

  • (String)

    the URL to the team’s Yahoo Fantasy page



50
# File 'lib/y_fantasy/resources/team.rb', line 50

option :url

#waiver_priorityInteger? (readonly)

Returns This team’s waiver priority.

Returns:

  • (Integer, nil)

    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

#managerManager

Returns the primary manager of the team

Returns:

  • (Manager)

    the primary manager (non-comanager) 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

Parameters:

  • week (Integer)

    the week number to get matchups for

Returns:

  • (Array<Matchup>)

    the matchups for the specified 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

Parameters:

  • week (Integer)

    the week number to get the roster for

  • player_stats (Boolean) (defaults to: false)

    Whether to include player stats

Returns:

  • (Roster)

    the roster for the specified 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_standingsHash

Returns a hash of simplified standings information for the team

Returns:

  • (Hash)

    a hash containing key standings information



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

Parameters:

  • week (Integer)

    the week number to get stats for

Returns:



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