Class: ChgkRating::Collections::Tournaments

Inherits:
Base show all
Defined in:
lib/chgk_rating/collections/tournaments/tournaments.rb

Constant Summary

Constants included from ChgkRating::Connection

ChgkRating::Connection::BASE_URL

Instance Attribute Summary collapse

Attributes inherited from Base

#items

Instance Method Summary collapse

Methods inherited from Base

#[], #convertable?, #each, #respond_to?, #to_a, #to_h

Methods included from Request

#get

Methods included from ChgkRating::Connection

#connection

Methods inherited from ChgkRating::ChgkObject

#build_model, #extract_id_from

Constructor Details

#initialize(params = {}) ⇒ Tournaments

Returns a new instance of Tournaments.



8
9
10
11
12
13
14
# File 'lib/chgk_rating/collections/tournaments/tournaments.rb', line 8

def initialize(params = {})
  @team = build_model params[:team]

  @season_id = params[:season_id]
  params[:lazy] = true if @team || @season_id
  super
end

Instance Attribute Details

#season_idObject (readonly)

Returns the value of attribute season_id.



6
7
8
# File 'lib/chgk_rating/collections/tournaments/tournaments.rb', line 6

def season_id
  @season_id
end

#teamObject (readonly)

Returns the value of attribute team.



6
7
8
# File 'lib/chgk_rating/collections/tournaments/tournaments.rb', line 6

def team
  @team
end

Instance Method Details

#revert_to_hash(key, values) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/chgk_rating/collections/tournaments/tournaments.rb', line 16

def revert_to_hash(key, values)
  [
    key,
    {
      'idteam' => @team&.id.to_s,
      'idseason' => key,
      'tournaments' => values.map(&:to_h)
    }
  ]
end