class SleeperRb::Resources::League

This class represents a Fantasy Football League and is the access point for associated resources. All attributes are lazily loaded and cache their value based on the API response.

Attributes

draft_id[R]
league_id[R]
name[R]
previous_league_id[R]
season[R]
season_type[R]
sport[R]
status[R]
total_rosters[R]

Public Class Methods

new(opts = {}) click to toggle source
Calls superclass method SleeperRb::Utilities::Cache::new
# File lib/sleeper_rb/resources/league.rb, line 143
def initialize(opts = {})
  raise ArgumentError unless opts[:league_id]

  super
end

Public Instance Methods

avatar() click to toggle source

Retrieves the Avatar instance for the league.

@return [SleeperRb::Resources::Avatar]

# File lib/sleeper_rb/resources/league.rb, line 49
      
drafts() click to toggle source

Returns all drafts for the league

@return [SleeperRb::Resources::DraftArray]

# File lib/sleeper_rb/resources/league.rb, line 128
cached_association :drafts do
  retrieve_drafts!
end
matchups(week_number) click to toggle source

Returns matchups for the League for the given week.

@return [SleeperRb::Resources::League::MatchupArray]

# File lib/sleeper_rb/resources/league.rb, line 110
cached_association :matchups do |week|
  retrieve_matchups!(week)
end
roster_positions() click to toggle source

Retrieves the available roster positions for the league.

@return [Array<SleeperRb::Utilities::RosterPosition>]

# File lib/sleeper_rb/resources/league.rb, line 61
      
rosters() click to toggle source

Retrieves rosters for the League.

@return [SleeperRb::Resources::League::RosterArray]

# File lib/sleeper_rb/resources/league.rb, line 90
cached_association :rosters do
  retrieve_rosters!
end
scoring_settings() click to toggle source

Retrieves the scoring settings for the league.

@return [SleeperRb::Resources::League::ScoringSettings]

# File lib/sleeper_rb/resources/league.rb, line 55
      
settings() click to toggle source

Returns the non-scoring settings for the league.

@return [SleeperRb::Resources::League::Settings]

# File lib/sleeper_rb/resources/league.rb, line 71
cached_attr :total_rosters, :status, :sport, :season_type, :season, :previous_league_id, :name, :league_id,
            :draft_id, avatar: ->(id) { Resources::Avatar.new(avatar_id: id) },
                       scoring_settings: ->(settings) { ScoringSettings.new(settings) },
                       roster_positions: lambda { |array|
                         array.map do |pos|
                           SleeperRb::Utilities::RosterPosition.new(pos)
                         end
traded_picks() click to toggle source

Returns all traded draft picks for the League.

@return [SleeperRb::Resources::TradedPickArray]

# File lib/sleeper_rb/resources/league.rb, line 119
cached_association :traded_picks do
  retrieve_traded_picks!
end
transactions(week_number) click to toggle source

Returns all transactions for the League for a given week.

@return [SleeperRb::Resources::League::TransactionArray]

# File lib/sleeper_rb/resources/league.rb, line 139
cached_association :transactions do |week|
  retrieve_transactions!(week)
end
users() click to toggle source

Retrieves users for the League.

@return [SleeperRb::Resources::UserArray]

# File lib/sleeper_rb/resources/league.rb, line 99
cached_association :users do
  retrieve_users!
end