Class: ChgkRating::Models::Team

Inherits:
Base show all
Defined in:
lib/chgk_rating/models/team.rb

Constant Summary

Constants included from Connection

Connection::BASE_URL

Instance Attribute Summary

Attributes inherited from Base

#lazy

Instance Method Summary collapse

Methods inherited from Base

#eager_load!, inherited, #initialize, no_eager_loading!, no_lazy_support!, #to_h

Methods included from Request

#get

Methods included from Connection

#connection

Methods inherited from ChgkObject

#build_model, #extract_id_from

Constructor Details

This class inherits a constructor from ChgkRating::Models::Base

Instance Method Details

#at_tournament(tournament_or_id) ⇒ ChgkRating::Models::TournamentTeam

Returns TournamentTeam for the current Team at a given tournament

Parameters:

  • tournament_or_id (String, Integer or Tournament)

    Tournament to load the team for

Returns:

Raises:


18
19
20
# File 'lib/chgk_rating/models/team.rb', line 18

def at_tournament(tournament_or_id)
  ChgkRating::Models::TournamentTeam.new self, tournament: tournament_or_id, lazy: true
end

#rating(release_id) ⇒ ChgkRating::Models::Rating

Returns Rating for the current Team in a given release

Parameters:

  • release_id (String or Integer)

    Release to load rating for.

Returns:


26
27
28
# File 'lib/chgk_rating/models/team.rb', line 26

def rating(release_id)
  ChgkRating::Models::Rating.new release_id, team: self
end

#ratingsChgkRating::Collection::Ratings

Returns an array-like Ratings collection for the current team.

Returns:

  • (ChgkRating::Collection::Ratings)

    The collection of ratings.


33
34
35
# File 'lib/chgk_rating/models/team.rb', line 33

def ratings
  ChgkRating::Collections::Ratings.new team: self
end

#recap(season_id) ⇒ ChgkRating::Models::Recap

Returns a single Recap for the current Team at a given season

Parameters:

  • season_id (String or Integer)

    Season to load recap for.

Returns:

Raises:


9
10
11
# File 'lib/chgk_rating/models/team.rb', line 9

def recap(season_id)
  ChgkRating::Models::Recap.new season_id, team: self
end

#recapsChgkRating::Collection::Recaps

Returns an hash-like Recaps collection for the current team, grouped by seasons. Seasons act as keys, whereas Recap models - as values.

Returns:

  • (ChgkRating::Collection::Recaps)

    The collection of recaps.


41
42
43
# File 'lib/chgk_rating/models/team.rb', line 41

def recaps
  ChgkRating::Collections::Recaps.new team: self
end

#tournaments(season_id: nil, params: {}) ⇒ ChgkRating::Collection::Tournaments

Returns a collection of Tournaments that the current team participated at based on the given criteria

Parameters:

  • season_id (String or Integer) (defaults to: nil)

    Season to load tournaments for

  • params (Hash) (defaults to: {})

    a customizable set of options

Options Hash (params:):

  • :page (String or Integer)

    The requested page. Default is 1

Returns:

  • (ChgkRating::Collection::Tournaments)

    The collection of tournaments.

Raises:


51
52
53
# File 'lib/chgk_rating/models/team.rb', line 51

def tournaments(season_id: nil, params: {})
  ChgkRating::Collections::Tournaments.new params.merge team: self, season_id: season_id, lazy: true
end