Class: SportsManager::GroupBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/sports_manager/group_builder.rb

Overview

Public: Builds a group with matches, teams, and participants from a payload

category - The matches’ category. subscriptions - The players subscribed. Doubles are represented as a nested list. matches - A list of matches. Each match is represented by a list of

players that will be participaing in it.

Example 1: A Team of one player Mixed single category with subscribed players: João, Marcelo, Bruno, and Fábio. The initial matches will be:

* Jo

Example 2: A team of two players Women’s double category with subscribed players: Laura, Karina, Camila, Bruna, Carolina, Patricia, Jéssica, and Daniela.

The initial matches will be:

* Laura and Karina vs J

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(category:, subscriptions:, matches:, tournament_type:) ⇒ GroupBuilder

Returns a new instance of GroupBuilder.



51
52
53
54
55
56
# File 'lib/sports_manager/group_builder.rb', line 51

def initialize(category:, subscriptions:, matches:, tournament_type:)
  @category = category
  @subscriptions = subscriptions
  @matches = matches
  @tournament_type = tournament_type
end

Instance Attribute Details

#categoryObject (readonly)

Returns the value of attribute category.



49
50
51
# File 'lib/sports_manager/group_builder.rb', line 49

def category
  @category
end

#matchesObject (readonly)

Returns the value of attribute matches.



49
50
51
# File 'lib/sports_manager/group_builder.rb', line 49

def matches
  @matches
end

#subscriptionsObject (readonly)

Returns the value of attribute subscriptions.



49
50
51
# File 'lib/sports_manager/group_builder.rb', line 49

def subscriptions
  @subscriptions
end

#tournament_typeObject (readonly)

Returns the value of attribute tournament_type.



49
50
51
# File 'lib/sports_manager/group_builder.rb', line 49

def tournament_type
  @tournament_type
end

Instance Method Details

#buildObject



58
59
60
# File 'lib/sports_manager/group_builder.rb', line 58

def build
  Group.new(category: category, matches: builded_matches, teams: teams)
end