Class: YFantasy::League
- Inherits:
-
BaseResource
- Object
- BaseResource
- YFantasy::League
- Defined in:
- lib/y_fantasy/resources/league.rb,
lib/y_fantasy/resources/league/settings.rb,
lib/y_fantasy/resources/league/standings.rb,
lib/y_fantasy/resources/league/scoreboard.rb
Overview
Represents a Yahoo Fantasy League.
Defined Under Namespace
Classes: Scoreboard, Settings, Standings
Instance Attribute Summary collapse
-
#allow_add_to_dl_extra_pos ⇒ Boolean
readonly
Whether the league allows adding extra positions to DL.
-
#current_week ⇒ Integer?
readonly
The current week number of the league.
-
#draft_results ⇒ Array<DraftResult>?
readonly
The draft results for the league.
-
#draft_status ⇒ String
readonly
The status of the draft.
-
#edit_key ⇒ String
readonly
The edit key for this league.
-
#end_date ⇒ Date
readonly
The end date of the league.
-
#end_week ⇒ Integer?
readonly
The final week of the league.
-
#felo_tier ⇒ String
readonly
The Fantasy ELO tier of the league.
-
#game_code ⇒ String
readonly
The game code (e.g. “nfl”, “nba”).
-
#is_cash_league ⇒ Boolean
readonly
Whether this is a cash league.
-
#is_finished ⇒ Boolean?
readonly
Whether the league has finished.
-
#is_pro_league ⇒ Boolean
readonly
Whether this is a pro league.
-
#league_id ⇒ String
readonly
The ID for this league.
-
#league_key ⇒ String
readonly
The unique key for this league.
-
#league_type ⇒ String
readonly
The type of league.
-
#league_update_timestamp ⇒ Integer
readonly
The timestamp of the last league update.
-
#logo_url ⇒ String
readonly
The URL for the league logo.
-
#name ⇒ String
readonly
The name of the league.
-
#num_teams ⇒ Integer
readonly
The number of teams in the league.
-
#players ⇒ Array<Player>?
readonly
The players in the league.
-
#renew ⇒ String
readonly
Previous league ID in the format “<game_id>_<league_id>”.
-
#renewed ⇒ String
readonly
Next league ID in the format “<game_id>_<league_id>”.
-
#scoreboard ⇒ Scoreboard?
readonly
The league scoreboard.
-
#scoring_type ⇒ String
readonly
The scoring type of the league.
-
#season ⇒ String
readonly
The season year of the league.
-
#settings ⇒ Settings?
readonly
The league settings.
-
#short_invitation_url ⇒ String?
readonly
The short URL for invitations to the league.
-
#standings ⇒ Standings?
readonly
The league standings.
-
#start_date ⇒ Date
readonly
The start date of the league.
-
#start_week ⇒ Integer?
readonly
The starting week of the league.
-
#teams ⇒ Array<Team>?
readonly
The teams in this league.
-
#url ⇒ String
readonly
The URL to the league’s Yahoo Fantasy page.
-
#weekly_deadline ⇒ String
readonly
The weekly deadline type.
Instance Method Summary collapse
-
#ended? ⇒ Boolean
Whether the league has ended.
-
#next_league_key ⇒ String?
Returns the key of the next/renewed league.
-
#previous_league_key ⇒ String?
Returns the key of the previous league.
-
#scoreboard_for_week(week) ⇒ Scoreboard
Gets the scoreboard for a specific week.
-
#started? ⇒ Boolean
Whether the league has started.
Methods inherited from BaseResource
collection_name, dependent?, find, find_all, #key, resource_name
Methods included from Subresourceable
Instance Attribute Details
#allow_add_to_dl_extra_pos ⇒ Boolean (readonly)
Returns Whether the league allows adding extra positions to DL.
19 |
# File 'lib/y_fantasy/resources/league.rb', line 19 option :allow_add_to_dl_extra_pos, Types::Params::Bool |
#current_week ⇒ Integer? (readonly)
Returns The current week number of the league.
107 |
# File 'lib/y_fantasy/resources/league.rb', line 107 option :current_week, optional: true, type: Types::Coercible::Integer |
#draft_results ⇒ Array<DraftResult>? (readonly)
Returns The draft results for the league.
125 |
# File 'lib/y_fantasy/resources/league.rb', line 125 option :draft_results, optional: true, type: array_of(DraftResult) |
#draft_status ⇒ String (readonly)
Returns The status of the draft.
23 |
# File 'lib/y_fantasy/resources/league.rb', line 23 option :draft_status |
#edit_key ⇒ String (readonly)
Returns The edit key for this league.
27 |
# File 'lib/y_fantasy/resources/league.rb', line 27 option :edit_key |
#end_date ⇒ Date (readonly)
Returns The end date of the league.
31 |
# File 'lib/y_fantasy/resources/league.rb', line 31 option :end_date, type: Types::Params::Date |
#end_week ⇒ Integer? (readonly)
Returns The final week of the league.
115 |
# File 'lib/y_fantasy/resources/league.rb', line 115 option :end_week, optional: true, type: Types::Coercible::Integer |
#felo_tier ⇒ String (readonly)
Returns The Fantasy ELO tier of the league.
35 |
# File 'lib/y_fantasy/resources/league.rb', line 35 option :felo_tier |
#game_code ⇒ String (readonly)
Returns The game code (e.g. “nfl”, “nba”).
39 |
# File 'lib/y_fantasy/resources/league.rb', line 39 option :game_code |
#is_cash_league ⇒ Boolean (readonly)
Returns Whether this is a cash league.
43 |
# File 'lib/y_fantasy/resources/league.rb', line 43 option :is_cash_league, Types::Params::Bool |
#is_finished ⇒ Boolean? (readonly)
Returns Whether the league has finished.
119 |
# File 'lib/y_fantasy/resources/league.rb', line 119 option :is_finished, optional: true, type: Types::Params::Bool |
#is_pro_league ⇒ Boolean (readonly)
Returns Whether this is a pro league.
47 |
# File 'lib/y_fantasy/resources/league.rb', line 47 option :is_pro_league, Types::Params::Bool |
#league_id ⇒ String (readonly)
Returns The ID for this league.
15 |
# File 'lib/y_fantasy/resources/league.rb', line 15 option :league_id |
#league_key ⇒ String (readonly)
Returns The unique key for this league.
11 |
# File 'lib/y_fantasy/resources/league.rb', line 11 option :league_key |
#league_type ⇒ String (readonly)
Returns The type of league.
51 |
# File 'lib/y_fantasy/resources/league.rb', line 51 option :league_type |
#league_update_timestamp ⇒ Integer (readonly)
Returns The timestamp of the last league update.
55 |
# File 'lib/y_fantasy/resources/league.rb', line 55 option :league_update_timestamp, Types::Coercible::Integer |
#logo_url ⇒ String (readonly)
Returns The URL for the league logo.
59 |
# File 'lib/y_fantasy/resources/league.rb', line 59 option :logo_url |
#name ⇒ String (readonly)
Returns The name of the league.
63 |
# File 'lib/y_fantasy/resources/league.rb', line 63 option :name |
#num_teams ⇒ Integer (readonly)
Returns The number of teams in the league.
67 |
# File 'lib/y_fantasy/resources/league.rb', line 67 option :num_teams, type: Types::Coercible::Integer |
#players ⇒ Array<Player>? (readonly)
Returns The players in the league. By default, only 25 players are returned.
129 |
# File 'lib/y_fantasy/resources/league.rb', line 129 option :players, optional: true, type: array_of(Player) |
#renew ⇒ String (readonly)
Returns Previous league ID in the format “<game_id>_<league_id>”.
72 |
# File 'lib/y_fantasy/resources/league.rb', line 72 option :renew |
#renewed ⇒ String (readonly)
Returns Next league ID in the format “<game_id>_<league_id>”.
77 |
# File 'lib/y_fantasy/resources/league.rb', line 77 option :renewed |
#scoreboard ⇒ Scoreboard? (readonly)
Returns The league scoreboard.
133 |
# File 'lib/y_fantasy/resources/league.rb', line 133 option :scoreboard, optional: true, type: instance_of(Scoreboard) |
#scoring_type ⇒ String (readonly)
Returns The scoring type of the league.
81 |
# File 'lib/y_fantasy/resources/league.rb', line 81 option :scoring_type |
#season ⇒ String (readonly)
Returns The season year of the league.
85 |
# File 'lib/y_fantasy/resources/league.rb', line 85 option :season |
#settings ⇒ Settings? (readonly)
Returns The league settings.
137 |
# File 'lib/y_fantasy/resources/league.rb', line 137 option :settings, optional: true, type: instance_of(Settings) |
#short_invitation_url ⇒ String? (readonly)
Returns The short URL for invitations to the league.
103 |
# File 'lib/y_fantasy/resources/league.rb', line 103 option :short_invitation_url, optional: true |
#standings ⇒ Standings? (readonly)
Returns The league standings.
141 |
# File 'lib/y_fantasy/resources/league.rb', line 141 option :standings, optional: true, type: instance_of(Standings) |
#start_date ⇒ Date (readonly)
Returns The start date of the league.
89 |
# File 'lib/y_fantasy/resources/league.rb', line 89 option :start_date, type: Types::Params::Date |
#start_week ⇒ Integer? (readonly)
Returns The starting week of the league.
111 |
# File 'lib/y_fantasy/resources/league.rb', line 111 option :start_week, optional: true, type: Types::Coercible::Integer |
#teams ⇒ Array<Team>? (readonly)
Returns The teams in this league.
145 |
# File 'lib/y_fantasy/resources/league.rb', line 145 option :teams, optional: true, type: array_of(Team) |
#url ⇒ String (readonly)
Returns The URL to the league’s Yahoo Fantasy page.
93 |
# File 'lib/y_fantasy/resources/league.rb', line 93 option :url |
#weekly_deadline ⇒ String (readonly)
Returns The weekly deadline type.
97 |
# File 'lib/y_fantasy/resources/league.rb', line 97 option :weekly_deadline |
Instance Method Details
#ended? ⇒ Boolean
Whether the league has ended
164 165 166 |
# File 'lib/y_fantasy/resources/league.rb', line 164 def ended? is_finished || Date.today > end_date end |
#next_league_key ⇒ String?
Returns the key of the next/renewed league
176 177 178 |
# File 'lib/y_fantasy/resources/league.rb', line 176 def next_league_key renewed&.split("_")&.join(".l.") end |
#previous_league_key ⇒ String?
Returns the key of the previous league
170 171 172 |
# File 'lib/y_fantasy/resources/league.rb', line 170 def previous_league_key renew&.split("_")&.join(".l.") end |
#scoreboard_for_week(week) ⇒ Scoreboard
Gets the scoreboard for a specific week
183 184 185 |
# File 'lib/y_fantasy/resources/league.rb', line 183 def scoreboard_for_week(week) @scoreboard = self.class.find(league_key, with: :scoreboard, week: week).scoreboard end |
#started? ⇒ Boolean
Whether the league has started
158 159 160 |
# File 'lib/y_fantasy/resources/league.rb', line 158 def started? Date.today >= start_date end |