Class: YFantasy::PickemTeam
- Inherits:
-
BaseResource
- Object
- BaseResource
- YFantasy::PickemTeam
- Defined in:
- lib/y_fantasy/resources/pickem_team.rb,
lib/y_fantasy/resources/pickem_team/pick.rb,
lib/y_fantasy/resources/pickem_team/week_pick.rb
Overview
Represents a Yahoo Fantasy Pick’em Team in a NFL Survival Group
Defined Under Namespace
Instance Attribute Summary collapse
-
#can_edit_current_week ⇒ Boolean?
readonly
Whether picks are editable for the current week.
-
#current_pick ⇒ String?
readonly
The current pick for this team.
-
#current_picks ⇒ Array?
readonly
The current picks for this team.
-
#eliminated ⇒ Boolean?
readonly
Whether this team has been eliminated.
-
#elimination_pick ⇒ String?
readonly
The pick that caused this team’s elimination.
-
#elimination_week ⇒ Integer
readonly
The week number when this team was eliminated.
-
#is_in_contest ⇒ Boolean?
readonly
Whether this team is in a contest.
-
#is_owned_by_current_login ⇒ Boolean?
readonly
Whether this team is owned by the current user.
-
#last_editable_week ⇒ String?
readonly
The last week number that can be edited.
-
#manager ⇒ Team::Manager?
readonly
The manager of this PickemTeam.
-
#name ⇒ String
readonly
The name of the PickemTeam.
-
#status ⇒ String?
readonly
The status of this PickemTeam.
-
#team_id ⇒ Integer
readonly
The ID for this PickemTeam.
-
#team_key ⇒ String
readonly
The unique key for this PickemTeam.
-
#total_strikes ⇒ Integer
readonly
The total number of strikes this team has.
-
#week_picks ⇒ Array<WeekPick>?
readonly
The weekly picks for this team.
Instance Method Summary collapse
-
#group ⇒ Group
Returns the group this PickemTeam belongs to.
-
#group_key ⇒ String
Returns the group key for this PickemTeam.
-
#key ⇒ String
Returns the key of this PickemTeam.
-
#true_total_strikes ⇒ Integer
Returns the “true” total strikes, based on the group end week.
-
#true_week_picks ⇒ Array<WeekPick>
Returns the week picks up to and including the group end week For some reason, Yahoo’s API can return more weeks than the group settings allow, and they are always strikes.
Methods inherited from BaseResource
collection_name, dependent?, find, find_all, resource_name
Methods included from Subresourceable
Instance Attribute Details
#can_edit_current_week ⇒ Boolean? (readonly)
Returns whether picks are editable for the current week.
32 |
# File 'lib/y_fantasy/resources/pickem_team.rb', line 32 option :can_edit_current_week, optional: true, type: Types::Params::Bool |
#current_pick ⇒ String? (readonly)
Returns the current pick for this team.
36 |
# File 'lib/y_fantasy/resources/pickem_team.rb', line 36 option :current_pick, optional: true |
#current_picks ⇒ Array? (readonly)
Returns the current picks for this team.
40 |
# File 'lib/y_fantasy/resources/pickem_team.rb', line 40 option :current_picks, optional: true |
#eliminated ⇒ Boolean? (readonly)
Returns whether this team has been eliminated.
44 |
# File 'lib/y_fantasy/resources/pickem_team.rb', line 44 option :eliminated, optional: true, type: Types::Params::Bool |
#elimination_pick ⇒ String? (readonly)
Returns the pick that caused this team’s elimination.
48 |
# File 'lib/y_fantasy/resources/pickem_team.rb', line 48 option :elimination_pick, optional: true |
#elimination_week ⇒ Integer (readonly)
Returns The week number when this team was eliminated.
26 |
# File 'lib/y_fantasy/resources/pickem_team.rb', line 26 option :elimination_week, type: Types::Coercible::Integer |
#is_in_contest ⇒ Boolean? (readonly)
Returns whether this team is in a contest.
52 |
# File 'lib/y_fantasy/resources/pickem_team.rb', line 52 option :is_in_contest, optional: true, type: Types::Params::Bool |
#is_owned_by_current_login ⇒ Boolean? (readonly)
Returns whether this team is owned by the current user.
56 |
# File 'lib/y_fantasy/resources/pickem_team.rb', line 56 option :is_owned_by_current_login, optional: true, type: Types::Params::Bool |
#last_editable_week ⇒ String? (readonly)
Returns the last week number that can be edited.
60 |
# File 'lib/y_fantasy/resources/pickem_team.rb', line 60 option :last_editable_week, optional: true |
#manager ⇒ Team::Manager? (readonly)
Returns the manager of this PickemTeam.
64 |
# File 'lib/y_fantasy/resources/pickem_team.rb', line 64 option :manager, optional: true, type: instance_of(Team::Manager) |
#name ⇒ String (readonly)
Returns The name of the PickemTeam.
18 |
# File 'lib/y_fantasy/resources/pickem_team.rb', line 18 option :name |
#status ⇒ String? (readonly)
Returns the status of this PickemTeam.
68 |
# File 'lib/y_fantasy/resources/pickem_team.rb', line 68 option :status, optional: true |
#team_id ⇒ Integer (readonly)
Returns The ID for this PickemTeam.
14 |
# File 'lib/y_fantasy/resources/pickem_team.rb', line 14 option :team_id, type: Types::Coercible::Integer |
#team_key ⇒ String (readonly)
Returns The unique key for this PickemTeam.
10 |
# File 'lib/y_fantasy/resources/pickem_team.rb', line 10 option :team_key |
#total_strikes ⇒ Integer (readonly)
Returns The total number of strikes this team has.
22 |
# File 'lib/y_fantasy/resources/pickem_team.rb', line 22 option :total_strikes, type: Types::Coercible::Integer |
#week_picks ⇒ Array<WeekPick>? (readonly)
Returns the weekly picks for this team.
74 |
# File 'lib/y_fantasy/resources/pickem_team.rb', line 74 option :week_picks, optional: true, type: array_of(WeekPick) |
Instance Method Details
#group ⇒ Group
Returns the group this PickemTeam belongs to
94 95 96 |
# File 'lib/y_fantasy/resources/pickem_team.rb', line 94 def group @group ||= Group.find(group_key, with: :settings) end |
#group_key ⇒ String
Returns the group key for this PickemTeam
88 89 90 |
# File 'lib/y_fantasy/resources/pickem_team.rb', line 88 def group_key @group_key ||= team_key.sub(/\.t\.\d+/, "") end |
#key ⇒ String
Returns the key of this PickemTeam
82 83 84 |
# File 'lib/y_fantasy/resources/pickem_team.rb', line 82 def key team_key end |
#true_total_strikes ⇒ Integer
Returns the “true” total strikes, based on the group end week. If the group allows two picks per week, fall back to ‘total_strikes` from the PickemTeam.
108 109 110 111 112 113 114 115 |
# File 'lib/y_fantasy/resources/pickem_team.rb', line 108 def true_total_strikes return total_strikes if group.settings.two_pick_start_week != 0 strikes = true_week_picks.count { |wp| wp&.picks&.first&.result == "strike" } return group.settings.max_strikes if strikes > group.settings.max_strikes strikes end |
#true_week_picks ⇒ Array<WeekPick>
Returns the week picks up to and including the group end week For some reason, Yahoo’s API can return more weeks than the group settings allow, and they are always strikes.
101 102 103 |
# File 'lib/y_fantasy/resources/pickem_team.rb', line 101 def true_week_picks @true_week_picks = week_picks&.slice(0, group.settings.end_week) end |